For XP, Windows provides SHGetFolderPath () to get a known location. The CSIDL you are looking for CSIDL_COMMON_APPDATAis described as:
, . "C:\Documents and Settings\All Users\Application Data". , . , , CSIDL_COMMON_APPDATA. , .
Vista SHGetKnownFolderPath(), SHGetFolderPath() - . Vista, FOLDERID_ProgramData CSIDL_COMMON_APPDATA.
, , .
, ( , Delphi):
function ShGetKnownFolderPath (
const rfid: TGUID;
dwFlags: DWord;
hToken: THandle;
out ppszPath: PWideChar): HResult;
var
Shell: HModule;
Fn: TShGetKnownFolderPath;
begin
Shell := LoadLibrary ('shell32.dll');
Win32Check(Shell <> 0);
try
@Fn := GetProcAddress (Shell, 'SHGetKnownFolderPath');
Win32Check (Assigned (Fn));
Result := Fn (rfid, dwFlags, hToken, ppszPath);
finally
FreeLibrary (Shell);
end;
end;
function GetKnownFolderPath (
const rfid: TGUID;
dwFlags: DWord;
hToken: THandle): WideString;
var
buffer: PWideChar;
ret: HResult;
begin
ret :=ShGetKnownFolderPath (rfid, dwFlags, hToken, buffer);
OleCheck (ret);
try
Result := buffer;
finally
CoTaskMemFree (buffer);
end;
end;
CSIDL_* FOLDERID_*. , , , "C:\Documents and Settings\<CurrentUser>\Application Data\". , Windows , , .