var
RegPath: string;
InstallLocationSubkey: string;
InstallLocationKey: string;
DisplayVersionValue: string;
function GetDefaultInstallDir(Param: string): string;
begin
// 设置要查询的注册表路径
RegPath := 'HKLM64,SubKey: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
InstallLocationSubkey:= 'DisplayVersion';
// 查询注册表
if RegQueryStringValue(HKLM64, RegPath, InstallLocationKey, DisplayVersionValue) then
begin
// 如果找到了 DisplayVersion 值,使用它来构造默认的安装路径
Result := 'InstallLocationSubkey ' + DisplayVersionValue;
end
else
begin
// 如果没有找到,则使用默认路径
Result := '{pf}\My Program';
end;
end;