// ChangeTest // Sample code for calling DinkeyChange.Dll #include #include #include "Visual Studio 5\DinkeyChange\resource.h" #include "ChangeTest.h" #ifdef _MSC_VER #pragma warning(disable:4996) // to disable warnings about sprintf etc... means we can use the same source for all compilers #endif char g_szAppName[] = "ChangeTest"; void DisplayError(int ret_code, int extended_error); // routine for main dialog box BOOL CALLBACK MainDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { int ret_code, i, num_found, confirmation_code, extended_error; char szType[4], szModel[5]; char szDisplayMsg[12800], szBuffer[257], szProdCode[9]; // these are the arrays that are filled-in by DCGetInfo int type[MAX_USB_DEVICES]; int model[MAX_USB_DEVICES]; char prodcode[MAX_USB_DEVICES][MAX_PRODCODE_LEN]; unsigned int dongle_number[MAX_USB_DEVICES]; int update_number[MAX_USB_DEVICES]; unsigned int machineID; switch (message) { case WM_INITDIALOG: // nothing to do break; case WM_COMMAND: // *** Get Dongle Information button clicked *** if (LOWORD(wParam) == IDC_DONGLEINFO && HIWORD(wParam) == BN_CLICKED) { // find dongle information for all dongle types, Plus & Net models, for all product codes // NB In practice you will probably want to set the prodcode_mask to the value of your product code ret_code = DCGetInfo(TYPE_MASK_ALL, MODEL_MASK_DEFAULT, NULL, MAX_USB_DEVICES, &num_found, type, model, prodcode, dongle_number, update_number); // check error code and display error if an error occurs if (ret_code == 401) { MessageBox(hwnd, "No dongles detected matching the search criteria specified", g_szAppName, MB_OK); return 0; } else if (ret_code != 0) { sprintf(szDisplayMsg, "Error %d getting dongle information", ret_code); MessageBox(hwnd, szDisplayMsg, g_szAppName, MB_OK); return 0; } // display info from dongle(s) detected szDisplayMsg[0] = 0; // null string for (i=0; i