获取 Windows 特殊文件夹的当前名称 [英] Get Current Names of Windows Special Folders

查看:22
本文介绍了获取 Windows 特殊文件夹的当前名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户可以轻松地将计算机、网络等特殊文件夹重命名为他们喜欢的任何名称.此外,如果计算机使用不同的语言环境,这些文件夹的名称也会不同.

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.

我想在我的应用程序中获取所有特殊文件夹的当前名称,如计算机、回收站、网络等.有没有办法做到这一点?特定的 API?注册表值?

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?

例如,用户将My Computer 重命名为Super Computer.我的应用程序应该显示 My Computer 的名称是 Super Computer.

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

推荐答案

他不是在寻找目录路径,他只是想要我的电脑"快捷方式的当前名称.

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

考虑是否右键单击我的电脑并单击重命名并将名称设置为Awesome Computer".如何通过 C# 找到这个值?

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#?

如果我打开 regedit 并在Awesome Computer"上进行查找",则会返回以下内容:

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}

您可以在 C# 中使用 Registry.GetValue 方法检索此值.您可以使用相同的方法将它们设置为唯一名称并运行注册表搜索来找到网络、回收站等的注册表路径.

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.

更新

看来,如果用户没有重命名我的电脑,并且仍然设置为默认值,那么注册表值将为空.在这种情况下,您可以查看以下注册表值以找到默认名称:

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 搜索...8964 回收站9216 我的电脑9217 网上邻居9227 我的文件9319 打印机和传真机

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

只需在注册表中搜索值@C:\WINDOWS\system32\SHELL32.dll 即可找到它们.

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

这篇关于获取 Windows 特殊文件夹的当前名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆