atul Site Admin
Joined: 18 Jul 2005 Posts: 8
|
Posted: Fri Jul 11, 2008 11:52 am Post subject: HOWTO: Reference the root folder of the namespace extension from a context menu extension or property sheet extension. |
|
|
It is possible to develop a context menu extension or a property sheet extension targeted at the root folder of the namespace extension, as described in http://www.ssware.com/support/viewtopic.php?t=345 and http://www.ssware.com/support/viewtopic.php?t=347
To reference the root folder from the extension, use the following code :
[C#]
// Create a new instance of the root folder of your namespace extension
FolderItem f = new FolderItem();
/*
In the below line, "\u37ff\u9351" is the signature and is required. "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" is the CLSID of 'My Computer' and is required only if the namespace extension is situated under 'My Computer'. If it is situated under the 'Desktop' it is not required; if it is under 'My Network Places', use the CLSID of that instead. Finally, "::{6EC97137-BE18-44b9-BB5B-92240A8D3481}" is the CLSID of your namespace extension as applied via the Guid attribute to the NSEFolder derived class representing the root folder of your namespace extension.
*/
string path = "\u37ff\u9351" + @"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{6EC97137-BE18-44b9-BB5B-92240A8D3481}";
// Initialize the 'root folder' with its full path
f.Initialize(Marshal.StringToCoTaskMemUni(path));
// After the 'root folder is initialized, it can be used as normal. For example :
f.RefreshView();
f.NotifyUpdated();
[VB.Net]
' Create a new instance of the root folder of your namespace extension
Dim f As FolderItem = New FolderItem()
/*
In the below line, "\u37ff\u9351" is the signature and is required. "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" is the CLSID of 'My Computer' and is required only if the namespace extension is situated under 'My Computer'. If it is situated under the 'Desktop' it is not required; if it is under 'My Network Places', use the CLSID of that instead. Finally, "::{6EC97137-BE18-44b9-BB5B-92240A8D3481}" is the CLSID of your namespace extension as applied via the Guid attribute to the NSEFolder derived class representing the root folder of your namespace extension.
*/
Dim charArr1() As Char = {ChrW(&H37FF), ChrW(&H9351)}
Dim signature As New String(charArr1)
Dim path As String = signature & "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{E9299950-0980-4E57-AE09-2B2EE69EDE28}"
' Initialize the 'root folder' with its full path
f.Initialize(Marshal.StringToCoTaskMemUni(path))
' After the 'root folder is initialized, it can be used as normal. For example :
f.RefreshView()
f.NotifyUpdated() |
|