Thema: Delphi Desktop Pfad

Einzelnen Beitrag anzeigen

Benutzerbild von SleepyMaster
SleepyMaster

Registriert seit: 18. Mai 2003
634 Beiträge
 
#2

Re: Desktop Pfad

  Alt 15. Apr 2004, 22:29
OK! Hat sich erledigt!

Delphi-Quellcode:



uses
  ActiveX, ShlObj;

function GetDeskTopPath : string;
var
  shellMalloc: IMalloc;
  ppidl: PItemIdList;
  PerDir: string;
begin
  ppidl := nil;
  try
    if SHGetMalloc(shellMalloc) = NOERROR then
    begin
      SHGetSpecialFolderLocation(Form1.Handle, CSIDL_DESKTOP, ppidl);
      SetLength(Result, MAX_PATH);
      if not SHGetPathFromIDList(ppidl, PChar(Result)) then
        raise exception.create('SHGetPathFromIDList failed : invalid pidl');
      SetLength(Result, lStrLen(PChar(Result)));
    end;
  finally
   if ppidl <> nil then
         shellMalloc.free(ppidl);
  end;
end;
  Mit Zitat antworten Zitat