Delphi - база знаний

Как найти системные папки Windows?


Как найти системные папки Windows?



Type TSystemPath=(Desktop,StartMenu,Programs,Startup,Personal, winroot, winsys);
...
Function GetSystemPath(SystemPath:TSystemPath):string;
var p:pchar;  
begin
with TRegistry.Create do  


try  
RootKey := HKEY_CURRENT_USER;  
OpenKey('\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', True);  
case SystemPath of  
Desktop: Result:=ReadString('Desktop');  
StartMenu:Result:=ReadString('Start Menu');  
Programs:Result:=ReadString('Programs');  
Startup:Result:=ReadString('Startup');  
Personal:Result:=ReadString('Personal');  
Winroot:begin  
GetMem(p,255);  
GetWindowsDirectory(p,254);  
result:=Strpas(p);  
Freemem(p);  
end;  
WinSys:begin  
GetMem(p,255);  
GetSystemDirectory(p,254);  
result:=Strpas(p);  
Freemem(p);  
end;  
end;  
finally  
CloseKey;  
free;  
end;  
if (result<>'') and (result[length(result)]<>'\') then result:=result+'\';  
end;

Автор Vit
Взято с Vingrad.ru




Содержание раздела