不知上面几个函数是在哪个单元 老东西。拿出来也许有用 uses shlobj, activex, comobj;{*************************************************************** * * 名 称 : GetSpecialFolder * 编 写: BlackFox * 说 明 : 取得指定的文件夹 * 入 口 : nFolder,文件夹索引,参看shlobj * 出 口 : 返回文件夹路径(无斜杠) * 历 史 : * 创建日期 :2001-05-30 ****************************************************************}function GetSpecialFolder(nFolder: Integer): string; var pIDL: pItemIDList; Buffer: array[0..MAX_PATH] of char; Malloc: IMalloc; begin try try OLECheck(SHGetMalloc(Malloc)); OLECheck(SHGetSpecialFolderLocation(0, nFolder, pIDL)); if ShGetPathFromIdList(pIDL, PChar(@Buffer)) then Result := Buffer else Result := ''; except Result := ''; end; finally if pIDL <> nil then Malloc.Free(pIDL); end;end;procedure TForm1.FormCreate(Sender: TObject); begin ShowMessage(GetSpecialFolder(CSIDL_APPDATA) + '\Microsoft\Templates\'); end;
'\Device\HarddiskVolume1\Documents and Settings\Administrator\Application Data\Microsoft\Templates\' 就是 'C:\Documents and Settings\Administrator\Application Data\Microsoft\Templates\'
procedure TForm1.Button1Click(Sender: TObject); var s1,s2:array[1..40] of char; begin GetWindowsDirectory(@s1,40); GetSystemDirectory(@s2,40); ShowMessage('Windows目录: '+s1); ShowMessage('System目录 :'+s2); end;
老东西。拿出来也许有用
uses shlobj, activex, comobj;{***************************************************************
*
* 名 称 : GetSpecialFolder
* 编 写: BlackFox
* 说 明 : 取得指定的文件夹
* 入 口 : nFolder,文件夹索引,参看shlobj
* 出 口 : 返回文件夹路径(无斜杠)
* 历 史 :
* 创建日期 :2001-05-30
****************************************************************}function GetSpecialFolder(nFolder: Integer): string;
var
pIDL: pItemIDList;
Buffer: array[0..MAX_PATH] of char;
Malloc: IMalloc;
begin
try try
OLECheck(SHGetMalloc(Malloc));
OLECheck(SHGetSpecialFolderLocation(0, nFolder, pIDL));
if ShGetPathFromIdList(pIDL, PChar(@Buffer)) then Result := Buffer
else
Result := ''; except
Result := ''; end;
finally
if pIDL <> nil then
Malloc.Free(pIDL);
end;end;procedure TForm1.FormCreate(Sender: TObject);
begin
ShowMessage(GetSpecialFolder(CSIDL_APPDATA) + '\Microsoft\Templates\');
end;
就是
'C:\Documents and Settings\Administrator\Application Data\Microsoft\Templates\'
var
s1,s2:array[1..40] of char;
begin
GetWindowsDirectory(@s1,40);
GetSystemDirectory(@s2,40);
ShowMessage('Windows目录: '+s1);
ShowMessage('System目录 :'+s2);
end;