怎样用API取得收藏夹目录?(200分)

  • 主题发起人 主题发起人 c-s-c
  • 开始时间 开始时间
C

c-s-c

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样只使用windows单元取得收藏夹目录?<br>怎样用API直接读取注册表值?最好是做成函数的.
 
uses<br>&nbsp; shlObj;<br>.....<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; p:pItemIDList;<br>&nbsp; buffer:array [ 0..255 ] of char ;<br>begin<br>&nbsp; SHGetSpecialFolderLocation(application.Handle,6,p);<br>&nbsp; SHGetPathFromIDList(p, buffer); &nbsp; &nbsp;<br>&nbsp; Label1.caption:=strpas(buffer);<br>end;
 
原来摘自本站,看原贴请用给出的ID<br><br>如何得到desktop, my computer等虚拟目录的guid? ( 积分:88, 回复:7, 阅读:42 )<br>分类:系统相关 ( 版主:luyear, zyy04 ) &nbsp;<br>来自:qevan, 时间:2003-3-12 1:10:00, ID:1673954 [显示:小字体 | 大字体] &nbsp;<br>最好有实例。<br>&nbsp;<br>&nbsp;<br>来自:adminmaker, 时间:2003-3-12 3:04:00, ID:1673987 <br>up<br>&nbsp;<br>&nbsp;<br>来自:qevan, 时间:2003-3-12 23:11:00, ID:1676929 <br>re一把,<br>本文在csdn也问了,但就是没人回答,<br><br>&nbsp;<br>&nbsp;<br>来自:小雨哥, 时间:2003-3-13 4:03:00, ID:1677066 <br>在 ShlObj 单元,自己去看。所有 CSIDL 开头的,共 35 个。<br>&nbsp;<br>&nbsp;<br>来自:小雨哥, 时间:2003-3-13 4:12:00, ID:1677067 <br>干脆让你看仔细了:<br>-------------------------------------------------------------------------------<br>uses ShlObj;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>const<br>&nbsp;Folder:array[0..34] of string=('CSIDL_DESKTOP',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_INTERNET',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_PROGRAMS',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_CONTROLS',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_PRINTERS',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_PERSONAL',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_FAVORITES',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_STARTUP',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_RECENT',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_SENDTO',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_BITBUCKET',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_STARTMENU',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'nil-13','nil-14','nil-15','nil-16',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_DESKTOPDIRECTORY',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_DRIVES',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_NETWORK',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_NETHOOD',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_FONTS',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_TEMPLATES',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_COMMON_STARTMENU',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_COMMON_PROGRAMS',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_COMMON_STARTUP',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_COMMON_DESKTOPDIRECTORY',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_APPDATA',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_PRINTHOOD',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_ALTSTARTUP','nil-30',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_COMMON_ALTSTARTUP',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_COMMON_FAVORITES',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_INTERNET_CACHE',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_COOKIES',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CSIDL_HISTORY');<br>var<br>&nbsp;PIIDList:PItemIDList;<br>&nbsp;PPath:array[0..255]of Char;<br>&nbsp;i:integer;<br>begin<br>&nbsp;for i:=0 to 34 do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;ZeroMemory(@PPath,256); <br>&nbsp; &nbsp; &nbsp;SHGetSpecialFolderLocation(self.Handle,i,PIIDList);<br>&nbsp; &nbsp; &nbsp;SHGetPathFromIDList(PIIDList,@PPath);<br>&nbsp; &nbsp; &nbsp;Memo1.Lines.Add(Folder+' : '+StrPas(@PPath));<br>&nbsp; &nbsp;end;<br>end;<br>&nbsp;<br>&nbsp;<br>来自:qevan, 时间:2003-3-13 16:34:00, ID:1679075 <br>谢谢,但我要的不是这个。<br>我想得到特殊目录的guid,<br>eg:{208D2C60-3AEA-1069-A2D7-08002B30309D}网上邻居<br>{20D04FE0-3AEA-1069-A2D8-08002B30309D}我的电脑<br>如何得到上面的guid?<br>比如通过 CSIDL 开头的那35个常量得到对应的guid.<br><br><br>&nbsp;<br>&nbsp;<br>来自:小雨哥, 时间:2003-3-13 19:52:00, ID:1679631 <br>CLSID_NetworkPlaces:TGUID={'208D2C60-3AEA-1069-A2D7-08002B30309D'};<br>CLSID_NetworkDomain:TGUID={'46e06680-4bf0-11d1-83ee-00a0c90dc849'};<br>CLSID_NetworkServer:TGUID={'c0542a90-4bf0-11d1-83ee-00a0c90dc849'};<br>CLSID_NetworkShare:TGUID={'54a754c0-4bf1-11d1-83ee-00a0c90dc849'};<br>CLSID_MyComputer:TGUID={'20D04FE0-3AEA-1069-A2D8-08002B30309D'};<br>CLSID_Internet:TGUID={'871C5380-42A0-1069-A2EA-08002B30309D'};<br>CLSID_ShellFSFolder:TGUID={'F3364BA0-65B9-11CE-A9BA-00AA004AE837'};<br>CLSID_RecycleBin:TGUID={'645FF040-5081-101B-9F08-00AA002F954E'};<br>CLSID_ControlPanel:TGUID={'21EC2020-3AEA-1069-A2DD-08002B30309D'};<br>CLSID_MyDocuments:TGUID={'450D8FBA-AD25-11D0-98A8-0800361B1103'};<br>CLSID_ShellDesktop:TGUID={'00021400-0000-0000-C000-000000000046'};<br>CLSID_ShellLink:TGUID={'00021401-0000-0000-C000-000000000046'};<br>&nbsp;<br>&nbsp;<br>来自:小雨哥, 时间:2003-3-13 19:59:00, ID:1679658 <br>看不清谁是谁的话,一个简单的办法是在桌面上新建一个文件夹,然后重命名时代入 GUID:<br>例如:把一个文件夹重命名为 X.{645FF040-5081-101B-9F08-00AA002F954E} ,就可以知道<br>这个 GUID 代表谁了。(本例是回收站)
 
修改自 kaida<br><br>program prjReg;<br><br>{$APPTYPE CONSOLE}<br><br>uses<br>&nbsp; Windows;<br><br>type<br>&nbsp; _SHITEMID = record<br>&nbsp; &nbsp; cb: Word;<br>&nbsp; &nbsp; abID: array[0..0] of Byte;<br>&nbsp; end;<br>&nbsp; TSHItemID = _SHITEMID;<br><br>&nbsp; PItemIDList = ^TItemIDList;<br>&nbsp; _ITEMIDLIST = record<br>&nbsp; &nbsp; &nbsp;mkid: TSHItemID;<br>&nbsp; &nbsp;end;<br>&nbsp; TItemIDList = _ITEMIDLIST;<br><br><br>function SHGetSpecialFolderLocation(hwndOwner: HWND; nFolder: Integer;<br>&nbsp; &nbsp; var ppidl: PItemIDList): HResult; stdcall; external 'shell32.dll';<br>function SHGetPathFromIDList(pidl: PItemIDList; pszPath: PChar): BOOL;<br>&nbsp; &nbsp; stdcall; external 'shell32.dll';<br><br>function GetFavoritePath: String;<br>var<br>&nbsp; p:pItemIDList;<br>&nbsp; buffer:array [ 0..255 ] of char ;<br>begin<br>&nbsp; SHGetSpecialFolderLocation(0,6,p);<br>&nbsp; SHGetPathFromIDList(p, buffer);<br>&nbsp; Result := String(buffer);<br>&nbsp; WriteLn(Result);<br>&nbsp; ReadLn;<br>end;<br><br>begin<br>&nbsp; GetFavoritePath;<br>&nbsp; { TODO -oUser -cConsole Main : Insert code here }<br>end.
 
非常感谢,正是需要的.
 
后退
顶部