Delphi 取得桌面文件夹的路径和取得我的文档的路径(转)

2017-11-15 10:47:42来源:oschina作者:小砍侃人点击

分享
UsesWindows,Registry;
function GetShellFolders(strDir: string): string;
const
regPath = '/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders';
var
Reg: TRegistry;
strFolders: string;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey(regPath, false) then begin
strFolders := Reg.ReadString(strDir);
end;
finally
Reg.Free;
end;
result := strFolders;
end;{获取桌面}function GetDeskeptPath: string;
begin
Result := GetShellFolders('Desktop'); //是取得桌面文件夹的路径
end;{获取我的文档}function GetMyDoumentpath: string;
begin
Result := GetShellFolders('Personal'); //我的文档
end;

复制代码

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台