Inno setup Inno安装程序获取默认浏览器
我有一个需要在用户计算机上安装默认浏览器的软件 有没有办法让我得到它 谢谢拿着这个:Inno setup Inno安装程序获取默认浏览器,inno-setup,pascalscript,Inno Setup,Pascalscript,我有一个需要在用户计算机上安装默认浏览器的软件 有没有办法让我得到它 谢谢拿着这个: function GetBrowser() : String; var RegistryEntry: String; Browser: String; Limit: Integer ; begin if RegQueryStringValue(HKEY_CLASSES_ROOT, 'http\shell\open\command', '', RegistryEntry) then beg
function GetBrowser() : String;
var
RegistryEntry: String;
Browser: String;
Limit: Integer ;
begin
if RegQueryStringValue(HKEY_CLASSES_ROOT, 'http\shell\open\command', '', RegistryEntry) then
begin
Limit := Pos('.exe' ,RegistryEntry)+ Length('.exe');
Browser := Copy(RegistryEntry, 1, Limit );
MsgBox('Your browser: ' + Browser , mbInformation, MB_OK);
end;
end;
在现代版本的Windows上正常工作的解决方案不能基于与
http
协议的关联,因为这不再可靠。它应该基于@GregT to的答案这样的解决方案
比如:
函数GetBrowserCommand:string;
变量
UserChoiceKey:string;
HtmlProgId:字符串;
开始
UserChoiceKey:=
“软件\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice”;
如果RegQueryStringValue(HKCU,UserChoiceKey,'ProgId',HtmlProgId),则
开始
日志(格式('ProgID to registed for.html为[%s]”,[HtmlProgId]);
如果RegQueryStringValue(HKCR,HtmlProgId+'\shell\open\command','',Result),则
开始
日志(格式('ProgID[%s]的命令为[%s]”,[HtmlProgId,Result]);
结束;
结束;
{旧版本Windows的回退}
如果结果='',则
开始
如果RegQueryStringValue(HKCR,'http\shell\open\command','',结果),则
开始
日志(格式('为http:[%s]注册的命令',[结果]);
结束;
结束;
结束;
如果要从命令中提取浏览器路径,请使用以下代码:
函数ExtractProgramPath(命令:string):string;
变量
P:整数;
开始
如果Copy(Command,1,1)='”,则
开始
删除(命令,1,1);
P:=Pos(“”,命令);
结束
否则P:=0;
如果P=0,则
开始
P:=位置('',命令);
结束;
结果:=复制(命令,1,P-1);
结束;
(基于)这在现代版本的Windows中不再适用。例如,我有
firefox.exe
,而我的默认浏览器是Chrome。有人在结束我的问题时说这就是答案,但我希望windows api能够检测到这一点。我知道您需要一个代码(尽管它没有使用Wiodows api)。但同样,这不再是有效的答案。正确答案必须基于@GregT at的答案。