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;
Ex:
{獲取桌面}
function GetDeskeptPath: string;
begin
Result := GetShellFolders('Desktop'); //是取得桌面資料夾的路徑
end;
{獲取我的文件}
function GetMyDoumentpath: string;
begin
Result := GetShellFolders('Personal'); //我的文件
end;
轉貼至: http://fecbob.pixnet.net/blog/post/38063575-delphi-取得桌面資料夾的路徑和取得我的文件
沒有留言:
張貼留言