Inno 设置:文件大小
InnoSetup: FileSize
我需要获取文件的大小。我需要检查文件是否超过 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; ,但只有当我需要检查尺寸是否正确时它才有效。但我无法检查或多或少
函数原型中的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;
我需要获取文件的大小。我需要检查文件是否超过 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; ,但只有当我需要检查尺寸是否正确时它才有效。但我无法检查或多或少
函数原型中的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;