2016-02-14 102 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