定位系统路径
function GetShellFolder( ID: Cardinal; Create: Boolean = False ): string;
// This function is a superset of SHGetSpecialFolderPath, included with
// earlier versions of the Shell. On systems preceeding those including
// Shell32.dll version 5.0 (Windows Millennium Edition (Windows Me) and
// Windows 2000), SHGetFolderPath was obtained through SHFolder.dll,
// distributed with Microsoft Internet Explorer 4.0 and later versions.
// Takes the CSIDL of a folder and returns the path or 'Could not determine
// folder path' if it does not exist. Creates the folder if it does not
// exist if Create is true.
var
Res: HResult;
Path: array [ 0 .. Max_Path ] of Char;
begin
if Create then
ID := ID or csidl_Flag_Create;
Res := ShGetFolderPath( 0, ID, 0, shgfp_Type_Current, Path );
if S_OK <> Res then
begin
Result := 'Could not determine folder path';
raise Exception.Create( 'Could not determine folder path' );
end;
Result := Path;
end;
GetShellFolder( CSIDL_LOCAL_APPDATA, False );