先添加个常量,如下:
{$R *.dfm} const cShellDesktop ='Desktop';
再添加个函数:
function TForm1.GetShellFolder(const folder: string): string; //获取桌面 const cWin32='SOFTWARE\Microsoft\Windows\CurrentVersion'; cSHellPrefix = '\Explorer\Shell Folders'; var r:TRegistry; begin Result:=''; r:=TRegistry.Create; try r.Rootkey:=HKEY_CURRENT_USER; if r.OpenKey (cWin32 + cShellPrefix, False) then Result:= r.ReadString (folder) + '\'; finally r.Free; end; end;
标签:delphi
发表评论