取得当前用户的桌面路径。

function GetDesktopFolder: string;
var
  buffr: array[0..MAX_PATH] of char;
  idList: PItemIDList;
begin
  Result := 'No Desktop Folder found.';
  SHGetSpecialFolderLocation(Application.Handle, CSIDL_DESKTOP, idList);
  if (idList <> nil) then
    if (SHGetPathFromIDList(idList, buffr)) then
      Result := buffr;
end;

你可能感兴趣的:(DELPHI)