Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.06.19;
Скачать: CL | DM;

Вниз

Срочный вопрос !!!! Как получить путь к Program Files ?   Найти похожие ветки 

 
SiJack ©   (2003-06-06 09:18) [0]

Может кто навскидку подскажет функцию ?


 
Внук ©   (2003-06-06 09:37) [1]

GetEnvironmentVariable("ProgramFiles",...)


 
SVM (Perm)   (2003-06-06 09:52) [2]

SHGetFolderPath


 
McSimm2   (2003-06-06 10:06) [3]


function GetProgramFilesDirByKeyStr(KeyStr: string): string;
var
dwKeySize: DWORD;
Key: HKEY;
dwType: DWORD;
begin
if
RegOpenKeyEx( HKEY_LOCAL_MACHINE, PChar(KeyStr), 0, KEY_READ, Key ) =
ERROR_SUCCESS
then
try
RegQueryValueEx( Key, "ProgramFilesDir", nil, @dwType, nil, @dwKeySize );
if (dwType in [REG_SZ, REG_EXPAND_SZ]) and (dwKeySize > 0) then
begin
SetLength( Result, dwKeySize );
RegQueryValueEx( Key, "ProgramFilesDir", nil, @dwType,
PByte(PChar(Result)),
@dwKeySize );
end
else
begin
RegQueryValueEx( Key, "ProgramFilesPath", nil, @dwType, nil, @dwKeySize
);
if (dwType in [REG_SZ, REG_EXPAND_SZ]) and (dwKeySize > 0) then
begin
SetLength( Result, dwKeySize );
RegQueryValueEx( Key, "ProgramFilesPath", nil, @dwType,
PByte(PChar(Result)),
@dwKeySize );
end;
end;
finally
RegCloseKey( Key );
end;
end;

function GetProgramFilesDir: string;
const
DefaultProgramFilesDir = "%SystemDrive%\Program Files";
var
FolderName: string;
dwStrSize: DWORD;
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
FolderName :=
GetProgramFilesDirByKeyStr("Software\Microsoft\Windows
NT\CurrentVersion");
end;
if Length(FolderName) = 0 then
begin
FolderName :=
GetProgramFilesDirByKeyStr("Software\Microsoft\Windows\CurrentVersion");
end;
if Length(FolderName) = 0 then FolderName := DefaultProgramFilesDir;
dwStrSize := ExpandEnvironmentStrings( PChar(FolderName), nil, 0 );
SetLength( Result, dwStrSize );
ExpandEnvironmentStrings( PChar(FolderName), PChar(Result), dwStrSize );
end;



 
SiJack ©   (2003-06-06 10:14) [4]

спасибо за помощь



Страницы: 1 вся ветка

Текущий архив: 2003.06.19;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.019 c
1-60171
ТОлег
2003-06-07 11:47
2003.06.19
Как скопировать один компонент в другой...


6-60313
first_aid
2003-04-15 08:13
2003.06.19
Indy, HTTPS и TIdConnectionInterceptOpenSSL.


14-60420
iluxa
2003-06-03 18:07
2003.06.19
Где купить Delphi 5


1-60175
XobBIT
2003-06-07 15:13
2003.06.19
Как в run-time добавить кнопки в TToolBar?


8-60270
Карелин Артем
2003-03-07 06:49
2003.06.19
Проигрывание видео и аудио из базы. Не сохраняя на винт.