Menu

Accessing the parallel port with inpout32.dll

2007-05-29
2012-09-26
  • Nobody/Anonymous

    I was trying to acces the parallel port with c++ by using the inpout32.dll, but i can't find a code that works.
    I have windows vista, and i'm using dev c++ 4.9.9.2.
    I was trying this:

    include <stdio.h>

    include <windows.h>

    typedef short _stdcall (inpfuncPtr)(short portaddr);
    typedef void _stdcall (
    oupfuncPtr)(short portaddr, short datum);

    int main(void)
    {
    HINSTANCE hLib;
    inpfuncPtr inp32;
    oupfuncPtr oup32;
    short data;
    int port;

    hLib = LoadLibrary("inpout32.dll");
    inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
    oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");

    port=0x378;
    data=255;
    (oup32)(port,data);
    printf("port write to 0x%X, datum=%hd\n" ,port,data);

    data=(inp32)(port);
    printf("port read (%04X)= %hd\n",port,data);

    FreeLibrary(hLib);
    system("pause");
    return 0;
    }

    but it doesn't work.

    Thank You for youre help.

     
    • Anonymous

      Anonymous - 2007-05-29

      It doesn't work in what respect? Does it compile, does it run, does it crash, does it simply appear to not do what you expect, or what?

      Apart from unnecessary inclusion of conio.h, the examples at http://www.hytherion.com/beattidp/comput/pport.htm should work.

      Clifford

       
      • Garth

        Garth - 2007-09-21

        Hi,
        I have been trying to use inpout32 with DevC for quite some time, but with no success. I tried Test2.c (and Test1.c) from the website quoted by slocombe

        http://www.hytherion.com/beattidp/comput/pport.htm

        and both programs compiled without any errors and can be run. They just do not return (read) the correct contents of the parallel port registers nor can they change (write) the contents of the registers. This suggests that the dll is not being implemented properly within DevC for some reason.

        While drwayne is correct that there are other threads on this forum regarding inpout32 and its use, I have yet to find anything that even approximates a solution.

        If anyone has been successful in using inpout32 with DevC, could they please post their code (or a simple example) so that others can see how things should be done, to make use of what would be a very useful dll.

        Thankyou

        Garth

         
    • Wayne Keen

      Wayne Keen - 2007-05-29

      This general topic has been discussed a number of times in the forum.

      A forum search should bring this up for you.

      Wayne

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.