我已经使用Visual Studio 2010 C#编写了一个类库,以读取计算机的硬件信息(例如HDD/SSD).我将使用该dll使用InnoSetup创建安装程序,以读取目标计算机的硬件信息.现在我的问题是,除非已注册,否则无法直接使用.NET dll.我正在尝试寻找一种在InnoSetup中的InitializeSetup期间注册dll的方法,以便可以使用dll中的功能.这是我为安装程序编写的脚本.
I have written a class library using Visual Studio 2010 C# to read hardware information of a Computer (e.g. HDD/SSD). I will use this dll to create an installer using InnoSetup to read the hardware info of the target computer. Now my problems is .NET dll cannot be used directly unless it is registered already. I am trying to find a way to register the dll during InitializeSetup in InnoSetup so I can use the functions in the dll. Here is the script I wrote for installer.
function InitializeSetup(): Boolean; var obj: Variant; diskPartitions: Integer; va: String; ErrorCode: Integer; b: Boolean; begin ExtractTemporaryFile('SSHardwareChecker.dll'); RegisterServer(False, ExpandConstant('{tmp}\SSHardwareChecker.dll'), False); obj := CreateOleObject('SSHardwareChecker.SSClass'); va := obj.GetDiskDriveInformation; MsgBox(va, mbInformation, mb_Ok); b:=UnregisterServer(False, ExpandConstant('{tmp}\SSHardwareChecker.dll'), False); end;函数RegisterServer似乎不起作用,它抛出一个错误,提示RegSvr32 failed with exit code 0x4.我在网上读了很多文章,说 dll应该使用regasm注册.我真的不知道如何做到这一点,尤其是在Inno Setup中.
The function RegisterServer doesn't seem to work.It throws an error which says RegSvr32 failed with exit code 0x4. I read a lot of articles in the net that says dll shoud be registered using regasm. I dont really know how to do this, especially in Inno Setup.
请帮助大家.
推荐答案尽管已使用了一年多,但我最近遇到了同样的问题,并且能够使用以下脚本进行纠正.
Though its more than a year, I recently had the same problem and was able to rectify using the below script.
[Run] Filename: "{dotnet20}\RegAsm.exe"; Parameters: /codebase YourDLL.dll; WorkingDir: {app}; StatusMsg: "Registering Controls..."; Flags: runminimized如果文件已在初始化步骤注册,则可以使用Inno设置程序的一种支持功能.
If the file has be registered at initialize step, we can use one of the Inno setup's support functions.
function Exec(const Filename, Params, WorkingDir: String; const ShowCmd: Integer; const Wait: TExecWait; var ResultCode: Integer): Boolean;
更多信息可在以下位置找到: Inno设置帮助
More Info can be found in: Inno Setup Help
更多推荐
如何使用Inno Setup注册.NET DLL
发布评论