【问题标题】:InnoSetup: FileSizeInno 设置:文件大小
【发布时间】:2015-08-05 18:15:55
【问题描述】:

我需要获取文件的大小。我需要检查文件是否超过 100b 示例:

If FileSize('C:\Program Files\MyProgramm\MyApp.exe') > 100 
   then
     msgbox ('File more then 100', mbinformation,mb_ok)
   else 
     msgbox ('File less then 100', mbinformation,mb_ok)

我看起来 function FileSize(const Name: String; var Size: Integer): Boolean; ,但它只有在我需要检查时才有效 - 大小是否正确。但我无法检查更多或更少

【问题讨论】:

  • 对不起,我不明白这个问题。您对FileSize 函数的调用无效。你需要一个Integer 类型的变量来接收大小。那么,您是在问如何调用该函数,还是对其结果有疑问?
  • 对不起我的英语,我需要示例如何使用功能或任何其他变体。我需要检查是 file0 字节还是更多?就是这样

标签: inno-setup


【解决方案1】:

函数原型中的var关键字意味着你需要声明一个给定类型的变量并将其传递给函数。然后该变量接收该值。这是FileSize 函数的示例:

var
  Size: Integer;
begin
  // the second parameter of the FileSize function is defined as 'var Size: Integer',
  // so we need to pass there a variable of type Integer, which is the Size variable
  // declared above
  if FileSize('C:\TheFile.any', Size) then
  begin
    if Size > 100 then
      MsgBox('The file is bigger than 100B in size.', mbInformation, MB_OK)
    else
      MsgBox('The file is smaller than 100B in size.', mbInformation, MB_OK);
  end
  else
    MsgBox('Reading the file size failed.', mbError, MB_OK);
end;

【讨论】:

  • 无论如何,如果它解决了您的问题,您可以考虑accepting this post(这是您可以随时更改的内容)。感谢并欢迎使用 Stack Overflow!
猜你喜欢
  • 1970-01-01
  • 2021-07-16
  • 2017-01-24
  • 2021-10-06
  • 1970-01-01
  • 1970-01-01
  • 2012-12-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多