Solved

get user path

Posted on 2004-10-23
417 Views
Last Modified: 2010-04-05
how can we get the path like "C:\Documents and Settings\my-user-acc\Local Settings\Application Data\Microsoft\Windows"
0
Question by:lehongwang
    2 Comments
     
    LVL 7

    Expert Comment

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

    0
     
    LVL 6

    Accepted Solution

    by:
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Anonabox PRO Tor & VPN Router

    PRO is the most advanced way to fortify your privacy and online anonymity by layering the Tor network with VPN services. Use both together or separately, and without needing to download software onto your devices.

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now