本文整理自网络,侵删。
我的电脑:SaveDialog1.InitialDir := '::{20D04FE0-3AEA-1069-A2D8-08002B30309D}';
// My Computer {20D04FE0-3AEA-1069-A2D8-08002B30309D}
// Network Neighborhood {208D2C60-3AEA-1069-A2D7-08002B30309D}
// Recycled {645FF040-5081-101B-9F08-00AA002F954E}
另外可使用SHGetSpecialFolder获取其它Windows虚拟文件夹,相关函数和常数定义于ShlObj。
如下面程序打开最近访问文件夹:
procedure TForm1.Button1Click(Sender: TObject);
var
PIDL: Pointer;
Path: LPSTR;
const
CSIDL_RECENT = $0008;
begin
Path := StrAlloc(MAX_PATH);
SHGetSpecialFolderLocation(Handle, CSIDL_RECENT, @PIDL);
if SHGetPathFromIDList(PIDL, Path) then // returns false if folder isn't part of file system
begin
OpenDialog1.InitialDir := Path;
OpenDialog1.Execute;
end;
StrDispose(Path);
end;
相关阅读 >>
Delphi application.restore不起作用了,该如何处理
Delphi winapi: getforegroundwindow - 获取前台窗口的句柄
Delphi winapi: gettopwindow - 获取指定窗口的子窗口中最顶层的窗口句柄
Delphi中转向语句break,continue,exit的作用
更多相关阅读请进入《Delphi》频道 >>