更新DLL服务器与Inno设置



我如何构造我的Inno Setup脚本自动注册一个dll,如果它是用户第一次安装我的应用程序,但取消注册以前的版本,如果有一个,然后注册新的(假设界面是不同的)?

我目前在我的文件部分使用regserver和ignoreversion标志,如下所示:

[Setup]
...
[Languages]
...
[Files]
Source: "C:example.dll"; DestDir: "{app}"; Flags: ignoreversion regserver

在我的谷歌搜索中,我发现了UnregisterServer,但我不知道如何将其添加到我的脚本。我很乐意开始修修补补,看看这是如何工作的,但我不想做任何会搞砸我的注册表。

这里有一个类似的帖子,但它没有说明这实际上是如何实现的。

编辑

在Pascal中破解后,我能够将以下内容添加到[Code]部分并且它工作了。有没有人知道如何使用{app}常量来动态定义下面代码中的fileName ?

[Code]
const
  fileName = 'C:Program FilesTFolderNametigercontroller.dll';
var
  serverExists: Boolean;
function InitializeSetup(): Boolean;
begin     
  serverExists := UnregisterServer(False, fileName, False);
  if serverExists then begin
    Result:= True;
    MsgBox('This will update with the most recent version', mbInformation, mb_Ok);
  end else
    Result := True;
end;

如何使用BeforeInstallAfterInstall参数文件?

用法是:

[Files]
Source: "MYDLL.DLL"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall;

BeforeInstall和AfterInstall函数不能有返回值!

procedure MyBeforeInstall();
begin
  // Your code here: If file (old) file exists call UnregisterServer() on old file
  // Use function FileExists(const Name: String): Boolean; or similar for it
  // Also you can delete the file entirely with function DeleteFile(const FileName: string): Boolean;
  // Hint: You can use 'CurrentFileName' variable to get currently processed file 
end;
procedure MyAfterInstall();
begin
  // Your (new) file was processed and now you can do additional tweaks on it
  // 'CurrentFileName' variable is still available 
  // Setup registers all files with the 'regserver' or 'regtypelib' flags as the last step of installation so in this function the file is still not registered!
end;

试试这个,它也可以处理32/64位并行COM服务器:

function UnregisterCOMServer(sServerCLSID: String): Boolean;varsServerPath:字符串;开始结果:= False;//在HKCR中搜索(合并视图)如果RegQueryStringValue(HKEY_CLASSES_ROOT, 'CLSID'+sServerCLSID+'InprocServer32', ', sServerPath)然后开始如果sServerPath<> "则开始日志('找到COM服务器CLSID:'+ sServerCLSID +',路径:'+sServerPath);结果:=UnregisterServer(False, sServerPath, True);if Result then Log('COM server '+ sServerCLSID +' unregistered.')else Log('UnregisterServer on '+ sServerPath +' failed!');结束else Log('没有找到COM服务器路径');结束else Log('COM server CLSID:'+ sServerCLSID +' not found!'+sServerPath);
 if Is64BitInstallMode then
 Begin
     if RegQueryStringValue(HKEY_CLASSES_ROOT, 'Wow6432NodeCLSID'+sServerCLSID+'InprocServer32', '', sServerPath) then
     Begin
        if sServerPath<>'' then
        Begin
            Log('Found COM server (Wow6432) CLSID:'+ sServerCLSID +', path:'+sServerPath);
            Result:=UnregisterServer(True, sServerPath, True);
            if Result then Log('COM server (Wow6432) '+ sServerCLSID +' unregistered.')
            else Log('UnregisterServer (Wow6432) on '+ sServerPath +' failed!');
        end
        else Log('No COM server (Wow6432) path found.');
     end
     else Log('COM server (Wow6432) CLSID:'+ sServerCLSID +' not found!'+sServerPath);
 end;
 之前

,

相关内容

  • 没有找到相关文章

最新更新