Delphi 取得桌面文件夾的路徑和取得我的文檔的路徑


Uses Windows,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;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM