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.