通过文件Inno Setup的环路和注册的每个.NET的DLL [英] Inno Setup Loop through files and register each .NET dll
问题描述
我使用Inno Setup的,我需要注册数目不详的使用regasm.exe文件.NET的DLL创建一个安装文件。我知道,我可以使用下面的code注册.NET的DLL。
I am creating a setup file using Inno Setup where I need to register unknown number of .net dlls using regasm.exe file. I know that I can use the following code to register .net dll.
[Run]
Filename: "{dotnet20}\RegAsm.exe"; Parameters: /codebase MyDLL.dll; WorkingDir: {app}; StatusMsg: "Registering Controls."; Flags: runminimized
我的问题是,在文件夹中的多个DLL文件,我不知道被注册的每个DLL的名称。有没有一种方法,我可以通过该文件夹中的文件回路并注册他们每个人不知道的文件和他们的名字有多少?
My problem is, there are more than one dlls in the folder and I don't know the name of each dll to be registered. Is there a way where I can loop through the files in the folder and register each one of them without knowing the number of files and their names?
请帮忙, 谢谢
推荐答案
我找不到任何标志,你如这将它们注册从 [文件]
部分,所以我写了这个剧本,它应该遍历指定文件夹中的所有* .dll文件,并为每个调用注册工具命令行。请注意,我没有测试过这个剧本,我不知道它的参数的命令行,但基本的思路应该是有:
I cannot find any flag which would register them for you e.g. from the [Files]
section, so I wrote this script, which should iterate all the *.dll files in the specified folder and for each call the registration tool command line. Please note, that I haven't tested this script, and I'm not sure about the used command line with its parameters, but the basic idea should be there:
[Code]
function RegisterNetLibraries(const Folder: string): Integer;
var
RegTool: string;
FindRec: TFindRec;
ResultCode: Integer;
begin
// initialize result to 0 processed files
Result := 0;
// expand the path to the registration tool
RegTool := ExpandConstant('{dotnet20}\RegAsm.exe');
// check if the registration tool exists; if not then exit...
if not FileExists(RegTool) then
begin
MsgBox('RegAsm.exe not found!' + #13#10 + RegTool, mbError, MB_OK);
Exit;
end;
// if we've found a *.dll file in the specified folder, then...
if FindFirst(ExpandConstant(Folder + '\*.dll'), FindRec) then
try
// repeat loop for every *.dll file in the specified folder
repeat
// if the iterated item is not a directory named like Dir.dll
if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
begin
// if the execution of the registration tool succeeded, then...
if Exec(RegTool, '/codebase ' + Folder + '\' + FindRec.Name,
ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated,
ResultCode)
then
// increase the returned processed file count
Result := Result + 1
else
// the execution failed, so let's try to show why
SysErrorMessage(ResultCode);
end;
until
// when there no next file item, the loop ends
not FindNext(FindRec);
finally
// release the allocated search resources
FindClose(FindRec);
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
Count: Integer;
begin
// if we are at the post installation step, then...
if CurStep = ssPostInstall then
begin
// the RegisterNetLibraries function returns count of processed files,
// don't forget that you must pass expanded constant values
Count := RegisterNetLibraries(ExpandConstant('{app}\Libs'));
// show how many files have been processed
MsgBox(IntToStr(Count) + ' libraries was processed...', mbInformation,
MB_OK);
end;
end;
这篇关于通过文件Inno Setup的环路和注册的每个.NET的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!