在静默模式下运行设置的正确方法是,始终使用
/SILENT
命令行参数执行它.例如这样:
setup.exe /SILENT
在我们在评论中澄清了您的要求后,我看到,您确实想要构建一个设置,它将在没有提到的命令行参数的情况下以静默模式运行.目前,没有内置的方法告诉编译器,您要构建静默设置,因此我们需要通过在初始化设置时使用/SILENT
命令行参数重新运行设置来解决此问题.
[Setup] AppName=My Program AppVersion=1.5 DefaultDirName={pf}\My Program [Code] #ifdef UNICODE #define AW "W" #else #define AW "A" #endif type HINSTANCE = THandle; function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string; lpParameters: string; lpDirectory: string; nShowCmd: Integer): HINSTANCE; external 'ShellExecute{#AW}@shell32.dll stdcall'; function InitializeSetup: Boolean; begin // if this instance of the setup is not silent which is by running // setup binary without /SILENT parameter,stop the initialization Result := WizardSilent; // if this instance is not silent,then... if not Result then begin // re-run the setup with /SILENT parameter; because executing of // the setup loader is not possible with ShellExec function,we // need to use a WinAPI workaround if ShellExecute(0,'',ExpandConstant('{srcexe}'),'/SILENT',SW_SHOW) <= 32 then // if re-running this setup to silent mode Failed,let's allow // this non-silent setup to be run Result := True; end; end;
原文地址:https://www.jb51.cc/vb/255536.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。