Einzelnen Beitrag anzeigen

Fritzew

Registriert seit: 18. Nov 2015
Ort: Kehl
678 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: Unit zur Verwendung von SHGetKnownFolderPath

  Alt 27. Sep 2016, 10:57
Hallo Ringli

Danke für die Unit,

aber eine Anmerkung: Dein Code gibt den Speicher nicht frei.


Ich habe es so geändert:

Delphi-Quellcode:
function GetKnownFolderPath(const rfid: TGUID): string;
var
  OutPath : PWideChar;
begin
  if ShGetKnownFolderPath(rfid, 0, 0, OutPath) {>= 0} = S_OK then
    begin
      Result := OutPath;
// From MSN
// ppszPath [out]
// Type: PWSTR*
// When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the known folder
// The calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree.
// The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\".
      CoTaskMemFree(OutPath);
    end
  else
    begin
      Result := '';
    end;
end;
Benötigt auch noch die WinApi.ActiveX im uses.
Fritz Westermann

Geändert von Fritzew (27. Sep 2016 um 11:38 Uhr)
  Mit Zitat antworten Zitat