Now, we're going to create a DLL file named BinaryToInteger.DLL This DLL is for converting “a character string of binary” into an integer value.
Example :
‘11111110’ = 254
The complete code of BinaryToInteger.DLL (click to download)
library BinaryToInteger;
uses
SysUtils,
Classes;
{$R *.RES}
function BinToInt(S : string) : integer; stdcall;
var
DataLength, i, j, buffer, buffer1 : integer;
begin
DataLength := Length(S);
buffer1 := 0;
for i := 1 to DataLength do
begin
buffer := StrToInt(S[i]);
for j := 1 to DataLength-i do buffer := buffer*2;
buffer1 := buffer1 + buffer;
end;
BinToInt := buffer1;
end;
exports
BinToInt;
begin
end.
To use this DLL file, you can see the example of using BinaryToInteger.DLL
0 comments:
Post a Comment