Windows有些文件夹可以通过读取注册表获取
获得“我的文档”文件夹需要读系统注册表HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders的Personal值。
程序代码:
uses Registry;
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey(Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders, False)
then edt1.text:= Reg.ReadString(Personal)
finally
Reg.CloseKey;
Reg.Free;
end;
end;