InpOut32.dll
-
ich benutz die Inpout32.dll um den LPT1
anzusprechen allerdings is da ein bug...
jedes mal wenn ich out32/inp32 nutz kackt mein prog wegen einer acces violation at 0x0000000000 ab.
ich hab die functions mit getprocaddress() importiert und wool grafgen uo mir jemand helfen kann.....
-
Okay.
-
compiler is egal ich hab versucht bcc32, cl und watcom keiner hab gefunzt...
-
Code?
-
#include <windows.h> #include <stdlib.h> #include <iostream.h> //PORTs const short &LPT1 = (0x378); const short &LPT2 = (0x278); const short &COM1 = (0x3F8); const short &COM2 = (0x458); //Offset for the parallel PORT const short &PORT = (LPT1); const short &DATA = (PORT + 0); const short &STATE = (PORT + 1); const short &CTRL = (PORT + 2); //Static LIB /* void __stdcall Out32(short, short); short __stdcall Inp32(short); inline short inp32(short portaddr) { Inp32(portaddr); } inline void out32(short portaddr, short datum) { Out32(portaddr, datum); } */ //Dynamic DLL // /* typedef short __stdcall (*inpfuncPtr)(short portaddr); typedef void __stdcall (*oupfuncPtr)(short portaddr, short datum); HINSTANCE dll; inpfuncPtr inp32; oupfuncPtr out32; bool init() { /* Load the library */ dll = LoadLibrary("inpout32.dll"); if (dll == NULL) { cout << "LoadLibrary Failed.\n"; return false; } /* get the address of the function */ inp32 = (inpfuncPtr) GetProcAddress(dll, "Inp32"); if (inp32 == NULL) { cout << "GetProcAddress for Inp32() Failed.\n"; return false; } out32 = (oupfuncPtr) GetProcAddress(dll, "Out32"); if (out32 == NULL) { cout << "GetProcAddress for out32() Failed.\n"; return false; } return false; } // */
#include <iostream> #include "inpout32.h" unsigned short data, ctrl, state; int execute; int main(int argc,char **argv) { std::cout << argc << "\n"; std::cout << **argv << "\n"; execute = false; for(int j = 0; j < argc;j++) { std::cout << *argv[j] << " "; } for(unsigned short int i = 0x0;i < 0xFF;i++) { std::cout << "ausführen ??? (inp32(STATE))"; std::cin >> execute; if(execute == true) { state = inp32(STATE); } else { std::cout << "closing......"; return 0; } std::cout << "ausführen ??? (inp32(DATA))"; std::cin >> execute; if(execute == true) { data = inp32(DATA); } else { std::cout << "closing......"; return 0; } std::cout << "ausführen ??? (inp32(CTRL))"; std::cin >> execute; if(execute == true) { ctrl = inp32(CTRL); } else { std::cout << "closing......"; return 0; } std::cout << "ausführen ??? (out32(DATA, i))"; std::cin >> execute; if(execute == true) { out32(DATA, i); } else { std::cout << "closing......"; return 0; } std::cout << "ausführen ??? (out32(STATE, i))"; std::cin >> execute; if(execute == true) { out32(STATE, i); } else { std::cout << "closing......"; return 0; } std::cout << "ausführen ??? (out32(CTRL, i))"; std::cin >> execute; if(execute == true) { out32(CTRL, i); } else { std::cout << "closing......"; return 0; } std::cout << data << "\n" << ctrl << "\n" << state << "\n"; } return 0; }
das wrs....
-
Zuviel unnötiger Code.
-
schau mal wann du init aufrufst und die "library" initialisierst
ansonsten solltest du bitte immer minimale Code Beispiele posten. Lies am besten mal wmfrs Wenn du dich an die Regeln hälst, bekommst du idr. schnell kompetente Antworten, aber die Sachen ergeben sich eigentlich wenn man über seine Posts mal nachdenkt