不,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'标志,想知道它是否可以与某种参数/另一个标志配对,这对我有帮助。我认为我阅读了文档中的所有相关部分,但希望我错过了一些内容。 –