| Код | type TSystemPath=(Desktop, StartMenu, Programs, ProgramFiles, Startup, Personal, winroot, winsys, WinTemp); TfmMain = class(TForm) ...
public Function GetSystemPath(SystemPath:TSystemPath):string;
...
implementation
Function TfmMain.GetSystemPath(SystemPath:TSystemPath):string; var p:pchar; Buffer: array[0..1023] of Char; 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('ProgramFiles'); Startup : Result := ReadString('Startup'); Personal : Result := ReadString('Personal'); WinTemp : SetString(Result, Buffer, GetTempPath(Sizeof(Buffer)-1,Buffer)); Winroot : begin GetMem(p,255); GetWindowsDirectory(p,254); result:=Strpas(p); Freemem(p); end;//winroot WinSys : begin GetMem(p,255); GetSystemDirectory(p,254); result:=Strpas(p); Freemem(p); end;//winsys ProgramFiles: begin CloseKey; RootKey := HKEY_LOCAL_MACHINE; OpenKey('\Software\Microsoft\Windows\CurrentVersion', FALSE); Result:=ReadString('ProgramFilesDir'); if Result = '' then Result:='C:\Program Files\'; end; end;//case finally result := IncludeTrailingPathDelimiter(result); CloseKey; free; end;//try-finally
end;
|
|