HINSTANCE hLib; cfunc1 Init_TCP; cfunc2 Close_TCP; cfunc3 Get_TCPKey; cfunc4 TCPTransfer; cfunc5 Get_TCPDeviceName; char mod[150]; int i; UCHAR inBuffer[16]; READ_BUFFER* pinBuffer; WRITE_BUFFER outBuffer; boolean load_DLL() { BOOLEAN dll_ok; hLib = LoadLibrary("ITRA_DEVCOMM.dll"); if (hLib != NULL) { dll_ok = TRUE; if (GetModuleFileName((HMODULE)hLib, (LPTSTR)mod, 150) == 0) dll_ok = FALSE; Init_TCP = (cfunc1)GetProcAddress((HMODULE)hLib,"Init_TCP"); Close_TCP = (cfunc2)GetProcAddress((HMODULE)hLib,"Close_TCP"); Get_TCPKey = (cfunc3)GetProcAddress((HMODULE)hLib,"Get_TCPKey"); TCPTransfer = (cfunc4)GetProcAddress((HMODULE)hLib,"TCPTransfer"); Get_TCPDeviceName = (cfunc5)GetProcAddress((HMODULE)hLib,"Get_TCPDeviceName"); } else { dll_ok = FALSE; } if (Init_TCP == NULL) dll_ok = FALSE; if (Close_TCP == NULL) dll_ok = FALSE; if (Get_TCPKey == NULL) dll_ok = FALSE; if (TCPTransfer == NULL) dll_ok = FALSE; if (Get_TCPDeviceName == NULL) dll_ok = FALSE; return dll_ok; } ... if (load_DLL() == TRUE) { // check the DLL if ((Init_TCP(0) & 0xFF00) == 0x3000) { // check the usb driver, 0 = TCP-Controller ... // Code request and LED output // fill the writeBuffer with LED vars outBuffer[0] = ~(outBuffer[0]); outBuffer[1] = ~(outBuffer[1]); outBuffer[2] = ~(outBuffer[2]); outBuffer[3] = ~(outBuffer[3]); pinBuffer=TCPTransfer(&outBuffer); /* // only Code request pinBuffer=Get_TCPKey(); */ if (pinBuffer->TransferResult == TRUE) { for (i=0;i<16;i++) { inBuffer[i]=pinBuffer->ReadBuffer[i]; } // process the key events in inBuffer[3], inBuffer[4] } else { // Transfer Error } // the Module can be leaved open for loops, but close it on program end Close_TCP(); } else { // Error Init } }