Geht es mit dieser Funktion?
Delphi-Quellcode:
...
function SHGetFolderPathW(hwndOwner: HWND; nFolder: Integer; hToken: THandle;
dwFlags: DWORD; pszPath: LPWSTR): HRESULT;
stdcall;
external '
shell32.dll'
name '
SHGetFolderPathW';
...
function GetSpecialDirectory(CSIDL: Integer;
Handle: Cardinal = 0):
String;
const
SHGFP_TYPE_CURRENT = 0;
var
APIResult: HRESULT;
Buffer:
Array[0 .. MAX_PATH - 1]
of WCHAR;
begin
Result := '
';
APIResult := SHGetFolderPathW(
Handle, CSIDL, 0, SHGFP_TYPE_CURRENT, Buffer);
if APIResult = S_OK
then
Result := SysUtils.IncludeTrailingPathDelimiter(WideString(Buffer));
end;