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;
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
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
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
This general topic has been discussed a number of times in the forum.
A forum search should bring this up for you.
Wayne