Elmo
Elmo

Reputation: 6471

Get Current Names of Windows Special Folders

Users can easily rename special folders like Computer, Network etc. to whatever they like. Also if the computer is using a different locale, the name of those folders will also be different.

I want to get the current names of all special folders like Computer, Recycle Bin, Network etc. in my app. Is there a way to do this? A specific API? A registry value?

For eg, user renames My Computer to Super Computer. My app should show that My Computer's name is Super Computer.

Upvotes: 0

Views: 866

Answers (1)

jzacharuk
jzacharuk

Reputation: 2116

He is not looking for a directory path, he simply wants the current name of the My Computer shortcut.

Consider if you right click on My Computer and click Rename and set the name to be "Awesome Computer". How can you find this value via C#?

If I open up regedit and do a "Find" on "Awesome Computer" the following is returned:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}

You can retrieve this value in C# using the Registry.GetValue method. You can find the registry path to the Network, Recycle Bin, etc using the same method of setting them to a unique name and running a registry search.

Update

It appears that if the user has not renamed My Computer, and it is still set to the default, then the registry value will be null. In this case you can look at the following registry value to find the default name:

HKEY_USERS\S-1-5-21-1070759151-1144338347-1905203885-52919\Software\Microsoft\Windows\ShellNoRoam\MUICache
@C:\WINDOWS\system32\SHELL32.dll,-9216

Here is a list of the different defaults:

8503 S&earch... 8964 Recycle Bin 9216 My Computer 9217 My Network Places 9227 My Documents 9319 Printers and Faxes

Just search for value @C:\WINDOWS\system32\SHELL32.dll in registry find them all.

Upvotes: 2

Related Questions