
Zitat von
f4r:
versteh kein wort von dem link das wer daher erstmal wo wenn ichs normal hinkrich :D
du fügst folgende units zu deinem programm:
Delphi-Quellcode:
uses
{ ... },
ActiveX,
// IMalloc
ShellAPI,
// SHGetSpecialFolderLocation() und SHGetPathFromIDList()
ShlObj;
// CSIDL_-Konstanten
dann bindest du diese funktion ein:
Delphi-Quellcode:
function GetSpecialFolder(hWindow: HWND; Folder: Integer): String;
var
pMalloc: IMalloc;
pidl: PItemIDList;
Path: PChar;
begin
// get IMalloc interface pointer
if (SHGetMalloc(pMalloc) <> S_OK) then
begin
MessageBox(hWindow, 'Couldn''t get pointer to IMalloc interface.',
'SHGetMalloc(pMalloc)', 16);
Exit;
end;
// retrieve path
SHGetSpecialFolderLocation(hWindow, Folder, pidl);
GetMem(Path, MAX_PATH);
SHGetPathFromIDList(pidl, Path);
Result := Path;
FreeMem(Path);
// free memory allocated by SHGetSpecialFolderLocation
pMalloc.Free(pidl);
end;
und rufst sie so auf:
Delphi-Quellcode:
SD.InitialDir := GetSpecialFolder(Application.Handle, CSIDL_DESKTOPDIRECTORY);
...
edit: das "Application.Handle, " vergessen.