InnoSetup:FileSize

时间:2015-08-05 10:02:24

标签: inno-setup

我需要获得File的大小。我需要检查文件是否超过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;,但只有在我需要检查尺寸时才能正常工作。但我不能或多或少地检查

1 个答案:

答案 0 :(得分: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;
相关问题