Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 具有依赖项的Inno安装驱动程序_C++_Windows_Installation_Driver_Inno Setup - Fatal编程技术网

C++ 具有依赖项的Inno安装驱动程序

C++ 具有依赖项的Inno安装驱动程序,c++,windows,installation,driver,inno-setup,C++,Windows,Installation,Driver,Inno Setup,我需要一些帮助,使一个Inno安装程序,我想在我自己的项目的同时安装驱动程序。 当驱动程序只是一个“exe”文件时,它工作正常: [Files] Source: ".\Component\Drivers\Driver1\driver1.exe"; DestDir: "{tmp}"; Check: Is64BitInstallMode; [Codes] ExtractTemporaryFile('driver1.exe'); Exec(ExpandConstant('{tmp}\driver1.e

我需要一些帮助,使一个Inno安装程序,我想在我自己的项目的同时安装驱动程序。 当驱动程序只是一个“exe”文件时,它工作正常:

[Files]
Source: ".\Component\Drivers\Driver1\driver1.exe"; DestDir: "{tmp}"; Check: Is64BitInstallMode;
[Codes]
ExtractTemporaryFile('driver1.exe');
Exec(ExpandConstant('{tmp}\driver1.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
但是,当司机对依赖关系更为复杂时,情况就不一样了。 我尝试将所有文件放在temp目录中(是的,这是丑陋的=),并执行驱动程序,但这个解决方案不起作用

[Files]
Source: ".\Component\Drivers\Keithley Driver\*"; DestDir: "{tmp}"; Check: Is64BitInstallMode;

[Code]
ExtractTemporaryFile('setup.exe');
Exec(ExpandConstant('{tmp}\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
你有什么好建议给我吗? 我可以将驱动程序及其所有依赖项压缩到一个“exe”文件中吗? 谢谢你的帮助,向你问好, 克莱门特

更新2: 这是我的entir代码:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "App"
#define MyAppVersion "1.0"
#define MyAppPublisher "Other"
#define MyAppURL "http://www.other.fr"
#define MyAppExeName "App.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
VersionInfoVersion={#MyAppVersion} 
AllowNoIcons=yes
OutputDir=.\Deployment
OutputBaseFilename=App-Setup
SetupIconFile=.\Component\App.ico
Compression=lzma
SolidCompression=yes
WizardImageFile=.\Component\App.bmp
WizardSmallImageFile=.\Component\App.bmp

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl";

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]                             
Source: ".\Component\Cal\*"; DestDir: "{app}\Cal"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\Component\Documentation\*"; DestDir: "{app}\Documentation"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\Component\Softwares\Utility\*"; DestDir: "{app}\Utility"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\Component\Softwares\System32\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\Component\Softwares\App\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source: ".\Component\Drivers\Keithley Driver\*"; Flags: deleteafterinstall createallsubdirs recursesubdirs; DestDir: "{tmp}";
Source: ".\Component\Drivers\Spec Driver\driver.exe"; DestDir: "{tmp}"; Check: Is64BitInstallMode;
Source: ".\Component\Drivers\Adaptater\adaptater.exe"; DestDir: "{tmp}"; Check: Is64BitInstallMode;

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
I: Integer;
begin
  // CurStep values
  // ssInstall, ssPostInstall, ssDone
  MsgBox('Hello.', mbInformation, MB_OK);
  if CurStep = ssPostInstall then begin
    Exec(ExpandConstant('{tmp}\Keithley Driver\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
    Exec(ExpandConstant('{tmp}\driver.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

    // Ask the user a Yes/No question
    if MsgBox('Do you need to use the Adaptater?', mbConfirmation, MB_YESNO) = IDYES then
    begin
      Exec(ExpandConstant('{tmp}\adaptater.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
      MsgBox('Please, plug it now!', mbInformation, MB_OK);
      for I := 0 to 10 do
      begin
        Sleep(400);
      end;
    end;
  end;
end;

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
更新3: 这是我安装具有依赖项的驱动程序的最后一个[代码]部分:

[Files]
Source: ".\Component\Drivers\*"; Flags: deleteafterinstall createallsubdirs recursesubdirs; DestDir: "{tmp}";

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
I: Integer;
begin
  // CurStep values
  // ssInstall, ssPostInstall, ssDone
  if CurStep = ssPostInstall then begin
    Exec(ExpandConstant('{tmp}\Keithley Driver\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
    Exec(ExpandConstant('{tmp}\Driver\driver.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

    // Ask the user a Yes/No question
    if MsgBox('Do you need to use the Adaptater?', mbConfirmation, MB_YESNO) = IDYES then
    begin
      Exec(ExpandConstant('{tmp}\Adaptater\adaptater.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
      MsgBox('Please, plug it now!', mbInformation, MB_OK);
      for I := 0 to 10 do
      begin
        Sleep(400);
      end;
    end;
  end;
end;

太多了,瑞克

我不知道你为什么要调用
ExtractTemporaryFile('setup.exe')如果其目标已经是{tmp}

我认为这就足够了(注意source和
deleteafterinstall
中的通配符):

我以为只有在源代码行中有
dontcopy
-标志时,才使用
ExtractTemporaryFile()
。然后该文件将不会被提取,您可以在代码中手动执行该操作。如果没有
dontcopy
-标志,您就不需要它


您的
[code]
段也不完整

下面是一个正在工作的.iss的小示例:

[Setup]
AppName=test
AppVerName=test
DefaultDirName=C:\TEMP
OutputBaseFilename=test
OutputDir=C:\TEMP
Uninstallable=no
;PrivilegesRequired=none
PrivilegesRequired=admin
Compression=lzma/ultra
SolidCompression=yes

[Files]
Source: ".\Component\Drivers\Keithley Driver\*"; Flags: deleteafterinstall createallsubdirs recursesubdirs; DestDir: {tmp}

[Code]

procedure CurStepChanged(CurStep: TSetupStep);
begin
  // CurStep values
  // ssInstall, ssPostInstall, ssDone
  if CurStep = ssPostInstall then begin
    MsgBox('Hello.', mbInformation, MB_OK);
    Exec(ExpandConstant('{tmp}\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  end;
end;

您的文件将位于ssPostInstall阶段的{tmp}目录中(而位于ssInstall阶段)。

但您将复制到tmp根目录,从而失去所有子文件夹-所有文件都位于主tmp目录中,而不是位于原始文件夹中的子目录中。这可能就是原因。尝试复制所有目录并保持目录布局(
标志:createallsubdirs recursesubdirs
),例如:
源:“.\Component\Drivers\Driver1\Keithley Driver\*”;DestDir:“{tmp}”;标志:dontcopy createallsubdirs recursesubdirs;检查:IS64BIInstallMode
然后尝试
提取临时文件('*')
(全部,保留目录布局),例如在
函数InitializeSetup()中:Boolean或任何你需要的地方。如果Rik的回答解决了你的问题,你应该接受它。您也可以通过单击接受复选标记旁边的向上箭头向上投票。现在您已经有足够的声誉来这样做;-)谢谢,欢迎来到StackOverflow!Thanx TLama,我已经检查并更新了他的答案!嗨,罗伯和里克,我已经像你说的那样修改了[文件]部分。但是对于[Code]部分,ExtractTemporaryFiles('*')不起作用,我真的需要使用“ExtractTemporaryFiles”,否则临时目录中没有任何内容是提取的。我尝试过这样提取:“ExtractTemporaryFile('.\Component\Drivers\Keithley Driver*');”但它不起作用。ExtractTemporaryFile不适用于目录。您需要调查{tmp}目录不包含这些文件的原因。它们在安装后立即被删除。所以也许他们在那里
deleteafterinstall
只是为了展示,因为我认为InnoSetup无论如何都会删除整个{tmp}(但使用它是一种很好的练习)。你能放一个
MsgBox('Hello',mbInformation,MB_OK)吗在Exec行上方,并查看%temp%dir中是否有innosetup中包含文件的子目录?此外,您的
[code]
也不完整,因为您应该有开始和结束标记、执行代码时的过程等。。。顺便说一句,您也可以在安装过程中使用“[run]标记来运行文件。我编辑了我的答案,以包含一个小示例。您的代码段需要更改一个过程CurStepChanged,并且在ssPostInstall阶段,您的文件将只在{tmp}中<代码>[run]
也在ssPostInstall阶段之后执行,因此您可以使用它。
[Setup]
AppName=test
AppVerName=test
DefaultDirName=C:\TEMP
OutputBaseFilename=test
OutputDir=C:\TEMP
Uninstallable=no
;PrivilegesRequired=none
PrivilegesRequired=admin
Compression=lzma/ultra
SolidCompression=yes

[Files]
Source: ".\Component\Drivers\Keithley Driver\*"; Flags: deleteafterinstall createallsubdirs recursesubdirs; DestDir: {tmp}

[Code]

procedure CurStepChanged(CurStep: TSetupStep);
begin
  // CurStep values
  // ssInstall, ssPostInstall, ssDone
  if CurStep = ssPostInstall then begin
    MsgBox('Hello.', mbInformation, MB_OK);
    Exec(ExpandConstant('{tmp}\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  end;
end;