📄 publicunit.pas
字号:
{******************************************************************************}
{Copyright(C) 2007,Pefine Security Lab }
{All rights reserved. }
{ }
{Abstract:View Win32 PE file information. }
{ }
{Version:1.01 }
{Author:WindRand }
{Date:2007-01-20 }
{******************************************************************************}
unit PublicUnit;
interface
uses SysUtils;
function StrToHex(InputStr:String):Integer;
function HexToInt(AHexStr: String): Integer;
function GetFileSize(FileNameStr:String):String;
implementation
function StrToHex(InputStr:String):Integer;
begin
if InputStr='0000' then
Result:=0;
if InputStr='0001' then
Result:=1;
if InputStr='0002' then
Result:=2;
if InputStr='0003' then
Result:=3;
if InputStr='0005' then
Result:=4;
if InputStr='0007' then
Result:=5;
if InputStr='0008' then
Result:=6;
if InputStr='0009' then
Result:=7;
if InputStr='000A' then
Result:=8;
if InputStr='000B' then
Result:=9;
if InputStr='000C' then
Result:=10;
if InputStr='000D' then
Result:=11;
if InputStr='000E' then
Result:=12;
end;
function HexCharToInt(AHexChar: Char) : Integer;
begin
case AHexChar of
'0' : Result:= 0;
'1' : Result:= 1;
'2' : Result:= 2;
'3' : Result:= 3;
'4' : Result:= 4;
'5' : Result:= 5;
'6' : Result:= 6;
'7' : Result:= 7;
'8' : Result:= 8;
'9' : Result:= 9;
'A','a' : Result:= 10;
'B','b' : Result:= 11;
'C','c' : Result:= 12;
'D','d' : Result:= 13;
'E','e' : Result:= 14;
'F','f' : Result:= 15;
end; {case}
end;
function HexToInt(AHexStr: String): Integer;
var
len ,i,j: integer;
temp: integer;
begin
Result:= 0;
temp:= 0;
len:= length(AHexStr);
for i:= len downto 1 do
begin
temp:= HexCharToInt(AHexStr[i]);
for j:=1 to len-i do
temp:= temp*16;
Result:= Result + temp;
end;
end;
//Get file size
function GetFileSize(FileNameStr:String):String;
var
fSize:Int64;
F:File;
KbInt:Double;
begin
try
Assign(F,FileNameStr);
Reset(F,1);
fSize:=FileSize(F);
finally
CloseFile(F);
end;
//Byte
if fSize<1024 then
begin
Result:='FileSize:'+IntToStr(fSize)+'Byte.';
Exit;
end;
//KB
if (fSize>=1024) and (fSize<(1024*1024)) then
begin
Result:='FileSize:'+Format('%0.1f',[fSize/1024])+'KB.';
Exit;
end;
//MB
if fSize>=1024*1024 then
begin
KbInt:=fSize div 1024;
Result:='FileSize:'+Format('%0.2f',[KBInt/1024])+'MB.';
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -