[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 161
  • Last Modified:

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

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?
0
haab
Asked:
haab
  • 3
1 Solution
 
sftwengCommented:
function DefaultSaveLocation: string;
var
  P: PChar;
begin
  {
    returns the location of 'My Documents' if it exists, otherwise it returns
    the current directory.
  }
  P := nil;
  try
    P := AllocMem(MAX_PATH);
    if SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, P) = S_OK then
      Result := P
    else
      Result := GetCurrentDir;
  finally
    FreeMem(P);
  end;
end;
0
 
sftwengCommented:
BTW, you'll need "uses SHFolder".
0
 
sftwengCommented:
This is code taken from creating a new project:

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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