HINSTANCE hLib; cfunc1 Init_MODULES; cfunc2 Close_MODULES; cfunc4 MODULESTransfer; cfunc5 GetMODULESDeviceName; char mod[150]; int i; UCHAR inBuffer[16]; READ_BUFFER* pinBuffer; WRITE_BUFFER outBuffer; boolean load_DLL() { BOOLEAN dll_ok; hLib = LoadLibrary("ITRA_APCOMM.dll"); if (hLib != NULL) { dll_ok = TRUE; if (GetModuleFileName((HMODULE)hLib, (LPTSTR)mod, 150) == 0) dll_ok = FALSE; Init_MODULES = (cfunc1)GetProcAddress((HMODULE)hLib,"Init_MODULES"); Close_MODULES = (cfunc2)GetProcAddress((HMODULE)hLib,"Close_MODULES"); MODULESTransfer = (cfunc4)GetProcAddress((HMODULE)hLib,"MODULESTransfer"); Get_MODULESDeviceName = (cfunc5)GetProcAddress((HMODULE)hLib,"Get_MODULESDeviceName"); } else { dll_ok = FALSE; } if (Init_MODULES == NULL) dll_ok = FALSE; if (Close_MODULES == NULL) dll_ok = FALSE; if (MODULESTransfer == NULL) dll_ok = FALSE; if (Get_MODULESDeviceName == NULL) dll_ok = FALSE; return dll_ok; } ... if (load_DLL() == TRUE) { // check the DLL if ((Init_MODULES(0) & 0xFF00) == 0x2200) { // check the usb driver ... // Code request and LED output // fill the writeBuffer with LED vars outBuffer[0] = ....; ... pinBuffer=MODULESTransfer(&outBuffer); 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_MODULES(); } else { // Error Init } }