get user path

how can we get the path like "C:\Documents and Settings\my-user-acc\Local Settings\Application Data\Microsoft\Windows"
lehongwangAsked:
Who is Participating?
 
Amir AzhdariCommented:
getspecialfolders :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,shlobj,activex;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure freepid1(pid1:pitemidlist);
var
allocator:imalloc;
begin
if succeeded(shgetmalloc(allocator)) then
allocator.Free(pid1);
end;


procedure TForm1.Button1Click(Sender: TObject);
var
pid1:pitemidlist;
buf:array[0..MAX_PATH] of char;
i:integer;
begin
memo1.Lines.clear;
for i :=0 to 100 do                 // i= CSIDL_DESKTOP or ... look in shlobj for other
if succeeded(shgetspecialfolderlocation(handle,i,pid1)) then
if shgetpathfromidlist(pid1,buf) then
memo1.Lines.Add(buf);


freepid1(pid1);

end;

end.
0
 
sftwengCommented:
Via the registry "HKCU" - see TRegistry in Help. See also: http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20869917.html

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.