我使用以下代码获取特殊目录
uses
ActiveX, ShlObj;
{...}
procedure TForm1.Button1Click(Sender: TObject);
// Replace CSIDL_HISTORY with the constants below
var
Allocator: IMalloc;
SpecialDir: PItemIdList;
FBuf: array[0..MAX_PATH] of Char;
PerDir: string;
begin
if SHGetMalloc(Allocator) = NOERROR then
begin
SHGetSpecialFolderLocation(Form1.Handle, CSIDL_PERSONAL, SpecialDir);
SHGetPathFromIDList(SpecialDir, @FBuf[0]);
Allocator.Free(SpecialDir);
ShowMessage(string(FBuf));
end;
end;
所以我用
但我怀疑这是所有windows电脑(personalfolder/documents)上的mydocuments路径,用户是否可以更改此结构并使mydocuments文件夹成为其他文件夹(例如:c:\ documents)
如果用户更改了路径,给了我一个正确的方法,我想知道My Documents文件夹的名称(mydocuments或Documents)