How to write to the disk when the (Windows XP) user is restricted?

Posted on 2004-11-02
Last Modified: 2010-07-27
I need to write to an INI file as well as storing temporary files on the user's disk while running my program. How do I find the user's root directory where he/she is authorized to write if he/she is a so called restricted user?
Question by:haab
    LVL 7

    Accepted Solution

    function DefaultSaveLocation: string;
      P: PChar;
        returns the location of 'My Documents' if it exists, otherwise it returns
        the current directory.
      P := nil;
        P := AllocMem(MAX_PATH);
        if SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, P) = S_OK then
          Result := P
          Result := GetCurrentDir;
    LVL 7

    Expert Comment

    BTW, you'll need "uses SHFolder".
    LVL 7

    Expert Comment

    This is code taken from creating a new project:

    File -> New -> Other -> Projects -> Win 2000 Logo Application

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    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…
    This video Micro Tutorial is the second in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 ( But the ability to create custom scanning profiles a…
    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!

    913 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

    18 Experts available now in Live!

    Get 1:1 Help Now