opening a port? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

opening a port?

does anyone know how to open a port in delphi?

thanx....

Comments

  • anthrax11anthrax11 Posts: 511Member
    : does anyone know how to open a port in delphi?
    :
    : thanx....
    :

    I found an piece of code that uses inline assembly:

    [code]function ReadPortB
    ( wPort : Word ) : Byte;
    begin
    asm
    mov dx, wPort
    in al, dx
    mov result, al
    end;
    end;

    procedure WritePortB
    ( wPort : Word; bValue : Byte );
    begin
    asm
    mov dx, wPort
    mov al, bValue
    out dx, al
    end;
    end;[/code]

    This may have problems with WinNT based systems, they dont like you having direct access to ports, but with some special programs you can make it work.

    Or you could try this one: http://www.logix4u.net/inpout32.htm
    You have to link the functions of the DLL to your application. Add these two lines of code to the implementation part:

    [code]function Inp32(wAddr: word): byte; stdcall; external 'inpout32.dll';
    function Out32(wAddr: word; bOut: byte): byte; stdcall; external 'inpout32.dll';[/code]

    Later, use the functions, for example:
    { Send 65 to port 378 }
    Out32($378,65);
    { Read port 378 }
    ShowMessage('Port $378:'+ IntToStr(Inp32($378)));

    Note, that this dll gives you 2 functions: Out32 and Inp32, nothing else.


    Hope it helps!

    Oh, were you talking about the internet related ports, which i have no idea of or did you mean the 65536 ports in your CPU?
    Hope it was the last one...



Sign In or Register to comment.