2016-02-14 106 views
-1

我试图让这个工作几个小时。这是almust工作。 我的情况是,我创建了一个安装程序与nsis,并希望做一个像Skype的链接(电话& Skype)和蒸汽(蒸汽:/ /加入/ 214456146),将启动我的程序与一些参数。如何使“此链接需要在程序中打开”链接(Windows注册表)

问题是我无法让它从链接发送参数到程序。 该程序正常工作,如果我与CMD运行它。

这里是一个(尝试)我NSIS代码登记在注册表中一些部分:

WriteRegStr HKCR "AudioOmega" "" "URL:AudioOmega Game Protocol" 
WriteRegStr HKCR "AudioOmega" "URL Protocol" "" 
WriteRegStr HKCR "AudioOmega\DefaultIcon" "" "$INSTDIR\game-controller.exe,1" 
WriteRegStr HKCR "AudioOmega\shell" "" "open" 
WriteRegStr HKCR "AudioOmega\shell\open\command" "" "$INSTDIR\game-controller.exe %1 %2 %3" 

另一个问题是,当我点击我的自定义协议的名称(audioomega链接:// PARMS )它提出了对话框,但它没有说AudioOmega游戏控制器它说的脚本的路径+%1,%2和%3

回答

0

你没有指定你正在谈论哪个对话框!所有主流浏览器都有自己的实现当你点击一个协议链接时出现的对话框。直接调用Windows Shell时,不会显示任何对话框。

当使用ShellExecute调用时,您可以指定额外的参数,但对于浏览器启动的某些内容,您需要将所有内容放在URI中,因为大多数实现只使用%1。

Internet Explorer使用FriendlyAppName值作为应用程序名称,如果存在的话:

Page Components 
Page InstFiles 

!include FileFunc.nsh 
!include LogicLib.nsh 

Function .onInit 
${GetParameters} $0 
${GetOptions} $0 "/uri=" $1 
${IfNot} ${Errors} 
    MessageBox MB_OK "Started as protocol.$\n$\nCommand line=$0" 
    Quit 
${EndIf} 
FunctionEnd 

Section "Register protocol" ; This example uses HKCU\Software\Classes and not HKCR so it works as non-admin 
WriteRegStr HKCU "Software\Classes\TestProto" "" "URL:TestProto Protocol" 
WriteRegStr HKCU "Software\Classes\TestProto" "FriendlyTypeName" "TestProto protocol" 
WriteRegStr HKCU "Software\Classes\TestProto" "URL Protocol" "" 
; Optional: UseOriginalUrlEncoding 
WriteRegExpandStr HKCU "Software\Classes\TestProto\DefaultIcon" "" "%SystemRoot%\system32\shell32.dll,6" 
WriteRegStr HKCU "Software\Classes\TestProto\shell" "" "open" 
WriteRegStr HKCU "Software\Classes\TestProto\shell\open" "FriendlyAppName" "Test app for TestProto protocol" 
WriteRegStr HKCU "Software\Classes\TestProto\shell\open\command" "" '"$exepath" /uri="%1" /params="%2 %3 %4"' 
SectionEnd 

Section "Test protocol" 
ExecShell "" "testproto://foo/bar?a=b&c=d" '1 "t w o" 3' 
InitPluginsDir 
FileOpen $0 "$PluginsDir\test.html" w 
FileWrite $0 '<html><body><a href="testproto://hello/world?a=b&c=d">Test</a></body></html>' 
FileClose $0 
ExecShell "" "$PluginsDir\test.html" 
SectionEnd 

Section "Unregister protocol" 
MessageBox MB_OK "Click OK to remove the protocol handler..." 
DeleteRegKey HKCU "Software\Classes\TestProto" 
SectionEnd