Link to home
Start Free TrialLog in
Avatar of charin1904
charin1904

asked on

How do I get System Path(Desktop) with Delphi2010?

function GetSystemPath(Folder: Integer): string;
var
  PIDL: PItemIDList;
  Path: LPSTR;
  AMalloc: IMalloc;
begin
  Path := StrAlloc(MAX_PATH);
  SHGetSpecialFolderLocation(Application.Handle, Folder, PIDL);

  if SHGetPathFromIDList(PIDL, Path) then Result := Path;

  SHGetMalloc(AMalloc);
  AMalloc.Free(PIDL);
  StrDispose(Path);
end;

Open in new window



Usage:

Showmessage(GetSystemPath(CSIDL_DESKTOPDIRECTORY));

-----------------------------------------------------------------------------

I normaly use function above on Delphi7, How do i convert it into Delphi 2010?

Thanks Expert!

Avatar of Thommy
Thommy
Flag of Germany image

You can use this under Delphi 2010...
function GetSysDir: string;
var
  Buffer: array[0..MAX_PATH + 1] of Char;
begin
  GetSystemDirectory(Buffer, MAX_PATH);
  Result := Buf;
end;

Open in new window

SOLUTION
Avatar of Thommy
Thommy
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of charin1904
charin1904

ASKER

Hi Thommy,

I"m sorry, question not clear, I need a "Desktop" Folder not system's folder :)

It something like:   C:\Users\Charin\Desktop

How do i get it?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the points...

:o)))
I got solution guided by Thommy.