• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

get user path

how can we get the path like "C:\Documents and Settings\my-user-acc\Local Settings\Application Data\Microsoft\Windows"
0
lehongwang
Asked:
lehongwang
1 Solution
 
sftwengCommented:
Via the registry "HKCU" - see TRegistry in Help. See also: http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20869917.html

0
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now