Inno Setup:重复的 InitializeSetup 合并

问题描述

我是编码尝试使用 Inno Setup 制作安装程序的菜鸟。
基本上,我正在尝试合并我在此站点上找到的两个代码一个用于进行 /VERYSILENT 安装,另一个用于在找不到注册表项时退出安装。
我已经知道我不能有两个 InitializeSetup 函数,如果我做对了,我必须使用事件属性合并它们。
我已经尝试以各种方式仅使用一个函数 InitializeSetup”来合并这两个函数,但通常这两个函数中只有一个代码有效,另一个似乎不可见。
我也尝试过使用事件属性命令,但我不知道如何正确使用它。

这是我使用两个 InitializeSetup 函数的初始代码

#include <stdio.h>

int main(void)
{
    int cases;      // Number of cases
    scanf("%d",&cases);

    int* nums = malloc(cases * sizeof *nums);   // Allocate enough space.

    /* Take the inputs. */
    for (int i = 0; i < cases; i++)
    {
        scanf("%d",(nums + i));
    }

    int cnt = 0;    // Counter for number of 1s.

    // Outer loop for going through cases.
    for (int i = 0; i < cases; i++)
    {
        // Inner loop for couting towards inputted number.
        for (int j = 0; j < *(nums + i) + 1; j++)
        {
            /* 
            *  You can Implement this part by yourself if you wish.
            */
            for (int k = 0; k < 32; k++)
            {
                if ((j >> (31 - k)) & 0x01) cnt++;  // Increment counter if digit is 1.
            }
            printf("%d ",cnt);
            cnt = 0;
        }
        printf("\n");
    }
    return 0;
}

在此先感谢能帮助我的人。

编辑

这是我从 Martin Prikryl 给我的链接中的示例中汇总的具有事件属性功能代码

#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';
//First one
function InitializeSetup: Boolean;
begin
 Result := WizardSilent;
 if not Result then
 begin
  if ShellExecute(0,'',ExpandConstant('{srcexe}'),'/VERYSILENT',SW_SHOW) <= 32
  then
   Result := True;
 end;
end;
//Second one
function InitializeSetup: Boolean;
begin
 Result := True;
 if not RegKeyExists(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion... etc. etc.') then
 begin
  Result := False;
 end;
end;

现在好像可以了。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)