不,Inno Setup不支持此操作。
但是從Pascal腳本中調用它並不難。
雖然請注意,您不能使用RegOverridePredefKey
將HKEY_LOCAL_MACHINE
重定向到HKEY_CURRENT_USER
。您只能將其重定向到一個子項:
hNewHKey:...一個開放註冊表項的句柄。該句柄由RegCreateKeyEx
或RegOpenKeyEx
函數返回。 它不能是預定義的鍵之一。
所以註冊DLL後,你將不得不子項複製到HKEY_CURRENT_USER
,並刪除它(爲RegOverridePredefKey
文檔建議)。
重定向到一個臨時的子項Basic代碼:
[Files]
Source: "MyDllServer.dll"; Flags: ignoreversion dontcopy
[Code]
const
KEY_WRITE = $20006;
function RegOverridePredefKey(Key: Integer; NewKey: Integer): Integer;
external '[email protected] stdcall';
function RegCreateKeyEx(
Key: Integer; SubKey: string; Reserved: Cardinal; Cls: Cardinal;
Options: Cardinal; Desired: Cardinal; SecurityAttributes: Cardinal;
var KeyResult: Integer; var Disposition: Cardinal): Integer;
external '[email protected] stdcall';
function MyDllRegisterServer: Integer;
external '[email protected]:MyDllServer.dll stdcall delayload';
{ ... }
begin
{ Create a subkey to redirect the HKLM to }
RegCreateKeyEx(HKEY_CURRENT_USER, 'MyProgTemp', 0, 0, 0, KEY_WRITE, 0, NewKey, Unused);
{ Redirect HKLM to the created subkey }
RegOverridePredefKey(HKEY_LOCAL_MACHINE, NewKey);
{ Call DllRegisterServer of the .dll }
MyDllRegisterServer;
{ Now you can copy the subkey to HKCU }
end;
添加一些錯誤處理!
該代碼適用於Unicode版本的Inno Setup。
對於複製的一部分,你可以從Specify the registry uninstall key location/hive via [Code]重用(提高)我的代碼。
你知道的方式? –
我不確定你的問題實際上是什麼。您是否問Inno Setup是否有內部調用'RegOverridePredefKey'的內置API(指令,標誌或任何其他內容),以便您不必以編程方式自己調用它? –
@MartinPrikryl好問題!錯誤的措辭也許:我不知道任何。我檢查了'regserver'標誌,想知道它是否可以與某種參數/另一個標誌配對,這對我有幫助。我認爲我閱讀了文檔中的所有相關部分,但希望我錯過了一些內容。 –