
21.08.2008, 18:49
|
 |
Sir Richard Abramson
|
|
Регистрация: 05.04.2008
Сообщения: 5,505
Версия Delphi: XE10
Репутация: выкл
|
|
Вот еще на всякий случай
Код:
type
TSystemPath = (spDesktop, spStartMenu,
spPrograms, spStartup, spPersonal, spAppData,
spFonts, spSendTo, spRecent, spFavorites, spCache,
spCookies, spHistory, spNetHood, spPrintHood,
spTemplates, spLocADat, spWindRoot, spWindSys,
spTempPath, spRootDir, spProgFiles, spComFiles,
spConfigPath, spDevicePath, spMediaPath, spWallPaper);
.........
function GetSystemPath(SystemPath: TSystemPath): string;
var
ph: PChar;
begin
with TRegistry.Create do
try
RootKey := HKEY_CURRENT_USER;
OpenKey('\Software\Microsoft\Windows\CurrentVersion\' +
'Explorer\Shell Folders', True);
case SystemPath of
spDesktop: Result := ReadString('Desktop');
spStartMenu: Result := ReadString('Start Menu');
spPrograms: Result := ReadString('Programs');
spStartup: Result := ReadString('Startup');
spPersonal: Result := ReadString('Personal');
spAppData: Result := ReadString('AppData');
spFonts: Result := ReadString('Fonts');
spSendTo: Result := ReadString('SendTo');
spRecent: Result := ReadString('Recent');
spFavorites: Result := ReadString('Favorites');
spCache: Result := ReadString('Cache');
spCookies: Result := ReadString('Cookies');
spHistory: Result := ReadString('History');
spNetHood: Result := ReadString('NetHood');
spPrintHood: Result := ReadString('PrintHood');
spTemplates: Result := ReadString('Templates');
spLocADat: Result := ReadString('Local AppData');
spWindRoot:
begin
GetMem(ph, 255);
GetWindowsDirectory(ph, 254);
Result := Strpas(ph);
Freemem(ph);
end;
spWindSys:
begin
GetMem(ph, 255);
GetSystemDirectory(ph, 254);
Result := Strpas(ph);
Freemem(ph);
end;
spTempPath:
begin
GetMem(ph, 255);
GetTempPath(254, ph);
Result := Strpas(ph);
Freemem(ph);
end;
spRootDir:
begin
GetMem(ph, 255);
GetSystemDirectory(ph, 254);
Result := (Copy(Strpas(ph), 1, 2));
Freemem(ph);
end;
end;
RootKey := HKEY_LOCAL_MACHINE;
OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion', True);
case SystemPath of
spProgFiles: Result := ReadString('ProgramFilesDir');
spComFiles: Result := ReadString('CommonFilesDir');
spConfigPath: Result := ReadString('ConfigPath');
spDevicePath: Result := ReadString('DevicePath');
spMediaPath: Result := ReadString('MediaPath');
spWallPaper: Result := ReadString('WallPaperDir');
end;
finally
CloseKey;
Free;
end;
{ if (Result <> '') and (Result[Length(Result)] <> '\') then
Result := Result + '\';}
end;
|