Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.014 c
14-60352
TRh
2003-05-28 15:42
2003.06.19
Восстанавливаем исходники


7-60425
Ик сик
2003-04-12 14:17
2003.06.19
Как послать в com-port Ctrl+P?


7-60426
BBCHa
2003-04-10 11:53
2003.06.19
Регистрация сервиса


8-60279
Дмитрий К.К.
2003-02-19 07:17
2003.06.19
Библиотека(и) для графики


14-60424
revo
2003-06-03 15:51
2003.06.19
Где скачать AsyncPro?




   Наверх