Click here to Skip to main content
15,867,453 members
Articles / Programming Languages / C# 4.0
Tip/Trick

Creating a Link in the Left Pane of the File Explorer - like OneDrive or DropBox

Rate me:
Please Sign up or sign in to vote.
4.89/5 (11 votes)
22 Aug 2016CPOL3 min read 33.2K   14   5
Creating a link in the left pane of the file Explorer - like OneDrive or DropBox

Introduction

I had a special requirement of adding a link in the left pane of the file explorer as one of the roots in the tree structure (like OneDrive or DropBox), which will opens that particular folder. I was roaming around the web to find some solution for this but didn't find any useful articles. This lead me to write this article after I completed the task through registry operations. I would like to share these experience with you.

Ways of Implementation

To implement this, you need a reserved GUID (which represents your entry), you can create your own GUID or it can be downloaded from here. Once you have the GUID (let it be "g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a" for this example), then you can follow any of the following steps to achieve this:

  • Editing required registry entries manually
  • Creating and executing registry file

Editing Required Registry Entries Manually

You need to do a series of registry operations in this method.

  1. Open Registry HKEY_CURRENT_USER then move on to KEY_CURRENT_USER\ Software\Classes\CLSID. Then, add a Key that is your guid.

  2. Select that key after creating them. Then you will be at [KEY_CURRENT_USER\Software\Classes\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}]. Add the following under this specific key.

    1. Select the Default string item in the right pane and set your App_Name as Data (say MyApp).

    2. A DWORD with Name "System.IsPinnedToNamespaceTree" and having a value of 1.

    3. Create another DWORD with name "SortOrderIndex" with a value 42.

    4. Create another Key named "DefaultIcon" which is to set the Icon of the shortcut in the left pane. And you have to specify the IconPath there in the data section of the default value.

    5. Next, we have to create another Key field named "InProcServer32" (not under the DefaultIcon) with specific data. "%SYSTEMROOT%\system32\shell32.dll" in the default value.

    6. The next Key that you have to create is "Instance", need not set any default value for this. But you have to create a string value inside this Instance which is called CLSID that should have a value of {0E5AAE11-A475-4c5b-AB00-C66DE400274E}.

    7. Now, we need to add a sub key named "InitPropertyBag" under the Instance (keep in mind your current location is HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{722f82b1-fd88-47b9-8af3-1d9ff79ebc76}\Instance). No need for any default value for this particular key.

    8. Move on to the new Key to create some values:

      1. Create an expandable string value (REG_EXPAND_SZ) "TargetFolderPath" which represents the location of the target folder, so you have to specify the local path here as the data for this field (let it be "C:\Users\Suji\MyApp").

      2. Create a DWORD "Attributes" with a Hex value of 11.

    9. You need to create the same keys, sub keys and values under HKEY_CURRENT_USER\SOFTWARE\Classes\Wow6432Node\CLSID for the 64 bit systems.

  3. First part is over. Now move on to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace. Create a key there for our GUID and the default value will be "MyApp".

  4. Move on to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel and create a DWORD with GUID as name and 1 as data.

  5. The process is completed. Now you can close the Registry editor, refresh the Explorer to see the Icon.

Creating and Executing Registry File

Copy the following code to a text file and save them with .reg extension, then run that file with administrator privilege.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}]
@="MyApp"
"System.IsPinnedToNamespaceTree"=dword:00000001
"SortOrderIndex"=dword:00000042

[HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\
{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\InProcServer32]
@=hex(2):25,00,53,00,59,00,53,00,54,00,45,00,4D,00,52,00,4F,00,4F,00,54,00,\
25,00,5C,00,73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,73,00,68,\
00,65,00,6C,00,6C,00,33,00,32,00,2E,00,64,00,6C,00,6C,00,00,00

[HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\ShellFolder]
"FolderValueFlags"=dword:00000028
"Attributes"=dword:f080004d

[HKEY_CURRENT_USER\Software\Classes\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}]
@="MyApp"
"System.IsPinnedToNamespaceTree"=dword:00000001
"SortOrderIndex"=dword:00000042

[HKEY_CURRENT_USER\Software\Classes\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\InProcServer32]
@=hex(2):25,00,53,00,59,00,53,00,54,00,45,00,4D,00,52,00,4F,00,4F,00,54,00,\
25,00,5C,00,73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,73,00,68,\
00,65,00,6C,00,6C,00,33,00,32,00,2E,00,64,00,6C,00,6C,00,00,00

[HKEY_CURRENT_USER\Software\Classes\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\ShellFolder]
"FolderValueFlags"=dword:00000028
"Attributes"=dword:f080004d

[HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\DefaultIcon]
@="C:\\Program Files (x86)\\Google\\Drive\\googledrivesync.exe,0"

[HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\Instance]
"CLSID"="{0E5AAE11-A475-4c5b-AB00-C66DE400274E}"

[HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\
{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\Instance\InitPropertyBag]
"Attributes"=dword:00000011
"TargetFolderPath"="C:\\Users\\Suji\\MyApp"

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel]
"{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}"=dword:00000001

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\
{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}]
@="MyApp"

[HKEY_CURRENT_USER\Software\Classes\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\DefaultIcon]
@="C:\Windows\System32\hwrreg.exe,0"

[HKEY_CURRENT_USER\Software\Classes\CLSID\{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\Instance]
"CLSID"="{0E5AAE11-A475-4c5b-AB00-C66DE400274E}"

[HKEY_CURRENT_USER\Software\Classes\CLSID\
{g16fa3ab-70d2-4fc7-9c99-fcbf05467f3a}\Instance\InitPropertyBag]
"Attributes"=dword:00000011
"TargetFolderPath"="C:\\Users\\Suji\\MyApp"

Points of Interest

You can implement the same through C# code. I will update the article with the code and sample solution for that.

History

This is the primary version.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Vanilla Networks Pvt.Ltd
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionNo MyApp being Displayed [Windows 10] Pin
deltamish22-Oct-18 21:40
deltamish22-Oct-18 21:40 
Hey,

I copy pasted your reg contents and even modified the Path to c:// .
I double click but nothing is being displayed. Tried your raw code and also modifed path

Can you provide guidance on how to do it. if you have a c# implementation even better

Thanks
AnswerRe: No MyApp being Displayed [Windows 10] Pin
smilanshah3-Mar-19 21:46
smilanshah3-Mar-19 21:46 
GeneralRe: No MyApp being Displayed [Windows 10] Pin
duncaner17-Sep-19 7:09
duncaner17-Sep-19 7:09 
QuestionFollow up Pin
piev18-Dec-17 12:41
piev18-Dec-17 12:41 
SuggestionYou should cite your source Pin
Simon Mourier20-Jan-17 20:31
Simon Mourier20-Jan-17 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.