如何使用 ISPP 将文件大小拆分为 DwinsHs_Check 函数的低位/高位

How to use ISPP to split a file size into lo / hi bits for the DwinsHs_Check function

接受这个脚本:

Source: "{tmp}\HelpDocSetup.exe"; \
    DestDir: "{app}"; \
    Flags: external deleteafterinstall; \
    Tasks: downloadhelp; \
    Check: DwinsHs_Check( ExpandConstant('{tmp}\HelpDocSetup.exe'), '{#HelpDocSetupURL}', 'My_Setup', 'Get', 0, 0 )

看到行尾的 0, 0 了吗?


根据 DwinsHs_Check 的文档,它指出:

  • FileSize : LongInt

    Together with the FileSizeHigh parameter specifies the file size in bytes. It will be used to calculate the download progress and remaining time. This avoids delays before the download begins because the script doesn't have to fetch the file size from the server.

    This parameter specifies the low 31 bits of the file size, and the FileSizeHigh parameter specifies the high 31 bits of the file size. Note, not 32 bits.

    Note, the file size will be fetched from the server if the parameter is set to FILESIZE_QUERY_SERVER (0), FILESIZE_UNKNOWN (-1), or FILESIZE_KEEP_FORMER (-2). In this case, the value of FileSize parameter will be ignored.

    Note, only digital value can be used in this parameter, the constant identifier cannot be used.

  • FileSizeHigh: LongInt

    Together with the FileSize parameter specifies the file size in bytes. It will be used to calculate the download progress and remaining time. This avoids delays before the download begins because the script doesn't have to fetch the file size from the server.

    This parameter specifies the high 31 bits of the file size, and the FileSize parameter specifies the low 31 bits of the file size.

    Note, the value of this parameter will be ignored if the FileSize parameter is set to FILESIZE_QUERY_SERVER (0), FILESIZE_UNKNOWN (-1), or FILESIZE_KEEP_FORMER (-2).

    Note, only digital value can be used in this parameter, the constant identifier cannot be used.


这个特定的安装文件也在我的电脑上。相对于主 ISS 文件,路径为:

..\HelpNDoc\CHM\Output\PublicTalksHelpDocumentationSetup.exe

我们可以使用 ISPP 提取文件大小并将其拆分为 DwinsHs_Check 所需的两个参数吗?

您可以使用 FileSize preprocessor function 检索文件大小。但它仅限于 2GB = 31 位。 DwinsHs_CheckFileSize 参数对应的内容:

#define ExeSize FileSize("..\HelpNDoc\CHM\Output\PublicTalksHelpDocumentationSetup.exe")

Check: DwinsHs_Check( ExpandConstant('{tmp}\HelpDocSetup.exe'), '{#HelpDocSetupURL}', \
       'My_Setup', 'Get', {#ExeSize}, 0)

如果文件理论上可以超过 2GB,您将不得不使用其他方式来检索文件大小——例如通过使用 Exec preprocessor function 调用 PowerShell 代码。并且您应该立即将大小拆分为 PowerShell(或其他)代码中的两部分,因为 Inno Setup 预处理器无论如何都无法处理 64 位数字。

有关调用 PowerShell 代码并返回其结果的示例,请参阅: