Friday, 28 May 2010

BinaryToInteger.DLL

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

These links are part of a pay per click advertising program called Infolinks. Infolinks is an In Text advertising service; they take my text and create links within it. If you hover your mouse over these double underlined links, you will see a small dialog box containing an advertisement related to the text. You can choose to move the mouse away and go on with your browsing, or to click on the box and visit the relevant ad. Click here to learn more about Infolinks Double Underline Link Ads.