FF e kadar copy post metodları ile alırsınız.
Hex ==> integer için
Kod: Tümünü seç
function HexToInt(HexNum: string): LongInt;
begin
Result:=StrToInt('$' + HexNum);
end;
16 tabanindaki sayinin ondalik sayiya çevrilmesi
Kod: Tümünü seç
procedure TForm1.Button1Click(Sender: TObject);
Const HEX : ARRAY['A'..'F'] OF INTEGER = (10,11,12,13,14,15);
var
str : String;
Int, i: integer;
begin
STR:=EDIT1.TEXT;
Int := 0;
for i := 1 TO Length(str) DO
if Str[i] < 'A' THEN Int := Int * 16 + ORD(str[i]) - 48
else Int := Int * 16 + HEX[str[i]];
Edit1.Text:=IntToStr(Int);
end;
Kod: Tümünü seç
function FileToHex(FileName: String): String;
var
F : DWORD;
Buffer : PChar;
FileSize : DWORD;
BytesRead : DWORD;
I : DWORD;
begin
Result := '';
F := CreateFile(PChar(FileName),GENERIC_READ,0,nil,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN);
If F = INVALID_HANDLE_VALUE Then Exit;
Try
FileSize := SetFilePointer(F,0,nil,FILE_END);
If FileSize = 0 Then Exit;
SetFilePointer(F,0,nil,FILE_BEGIN);
Buffer := AllocMem(FileSize);
If Buffer = nil Then Exit;
Try
ReadFile(F,Buffer^,FileSize,BytesRead,nil);
If BytesRead <> FileSize Then Exit;
For I := 0 To BytesRead Do
begin
Result := Result + IntToHex(Byte(Buffer^),2);
Inc(Buffer);
end;
Finally
FreeMem(Buffer);
end;
Finally
CloseHandle(F);
end;
end;