简体   繁体   English

如何从其他用户中找到MyMusic文件夹?

[英]how to find MyMusic Folder from other users?

如何找到其他用户的MyMusic文件夹?

您可以将Environment.SpecialFolder枚举与Environment.GetFolderPath一起使用,以访问“特殊”用户文件夹,如下所示:

Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);

The documented way to do this is to use SHGetFolderLocation and the hToken parameter, the problem is that you need the username and password to call LogonUser (You could also call WTSQueryUserToken if you are running as a service, but that limits you to the currently active sessions) 记录的执行此操作的方法是使用SHGetFolderLocation和hToken参数,问题在于您需要用户名和密码才能调用LogonUser(如果您作为服务运行,也可以调用WTSQueryUserToken ,但这将您限制为当前处于活动状态会议)

Now you are left with using undocumented stuff : 现在您剩下使用未记录的东西了

  1. Find the profile: HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList (%windir%\\Profiles on Win9x) 查找配置文件: HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList (在Win9x上为%windir%\\ Profiles)
  2. AdjustTokenPrivileges for SE_RESTORE_NAME SE_RESTORE_NAME AdjustTokenPrivileges
  3. RegLoadKey NTUSER.DAT (USER.DAT on 9x) RegLoadKey NTUSER.DAT(9x上的USER.DAT)
  4. Query HKEY_USERS\\{SIDYOUGOTFROMPROFILELIST}\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders 查询HKEY_USERS\\{SIDYOUGOTFROMPROFILELIST}\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders

Note: You need to be admin to do this and it only works for local accounts. 注意:您需要成为管理员才能执行此操作,并且仅适用于本地帐户。

If the account you are running the program on has administrative privlieges, can't you just navigate to c:\\Users\\<UserName>\\Music (which is the path on Windows7). 如果您在其上运行程序的帐户具有管理特权,那么您是否只能浏览到c:\\Users\\<UserName>\\Music (这是Windows7上的路径)。
If you're looking for folders of users on another machine, then that is more difficult. 如果要在另一台计算机上查找用户文件夹,则更加困难。

EDIT: It appears that there is a way to do this, from MSDN : 编辑:似乎有一种方法可以从MSDN执行

HRESULT SHGetKnownFolderPath(
  __in   REFKNOWNFOLDERID rfid,
  __in   DWORD dwFlags,
  __in   HANDLE hToken,
  __out  PWSTR *ppszPath
);

With the rfid being the KNOWNFOLDERID of the folder you are looking for in the case of My Music: 对于“我的音乐”,rfid是您要查找的文件夹的KNOWNFOLDERID:

GUID{2112AB0A-C86A-4FFE-A368-0DE96E47012E}
Display NameMusicFolder 
Type PERUSER
Default Path: %APPDATA%\Microsoft\Windows\Libraries\Music.library-msCSIDL 
Equivalent None, new in Windows 7
Legacy Display Name Not applicable
Legacy Default Path Not applicable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM