/* =================================================================== For Microsoft MFC then change the FARPROC to typedef CHAR* (__stdcall* CRC32FILECHECKPTR)(char*); // FARPROC CRC32FileCheck = GetProcAddress (hinstDLL,"CRC32FileCheck"); CRC32FILECHECKPTR CRC32FileCheck = (CRC32FILECHECKPTR) GetProcAddress (hinstDLL,"CRC32FileCheck"); and the MessageBox function only has three parms when run from a MFC app. Also the ShareGuardLock function has to be put in the header file where the class is defined. =================================================================== */ /* =============================================== */ /* C and/or C++ Example Code For yourprogram.exe */ /* =============================================== */ /* === Start ShareGuard Lock Main ================ */ /* Add this code to your mainline initialization or form create */ //#include //If using Borlands #include //If using MS Visual C++ // Add this code to main() or WinMain() BOOLEAN bShutdown; // Declarative required for ShareGuard Lock - True or False bShutdown = ShareGuardLockTest(); // Call Subroutine to invoke ZSSGCRC32.DLL and ZSGLOCK.DLL if (bShutdown == TRUE) { MessageBox(0, "Application will be shut down due to previous reason.","Error!",MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); return 0; } /* === End ShareGuard Lock Main ================== */ /* ----------------------------------------------- */ /* === Start ShareGuard Lock Suboutine =========== */ /* ----------------------------------------------- */ /* ShareGuard Lock Routine */ /* Returns the boolean result of whether the */ /* application should be shut down. */ /* TRUE - shut down the application */ /* FALSE - application is fine */ /* Files Required: */ /* - yourprogram.exe */ /* - ZSSGL.EXE */ /* - ZSSGLOCK.DLL */ /* - ZSSGCRC32.DLL */ /* ----------------------------------------------- */ BOOL ShareGuardLockTest() { BOOLEAN bShutdown; CHAR *hexresult; CHAR *reasoncode; INT i; CHAR *myresult; CHAR *myreasoncode = "0"; char *filename = "ZSSGLOCK.DLL"; char *hexanswer = "7DB4D285"; char *rcanswer = "0"; HINSTANCE hinstDLL = LoadLibrary ("ZSSGCRC32.DLL"); FARPROC CRC32FileCheck = GetProcAddress(hinstDLL,"CRC32FileCheck"); HINSTANCE hinstLockDLL = LoadLibrary ("ZSSGLOCK.DLL"); FARPROC ShareGuardLock = GetProcAddress (hinstLockDLL,"ShareGuardLock"); /* === Start ShareGuard Lock Parameters ========== */ /* Put the ShareGuard Locksmith Generated Parameters in here */ char *lockparms = "ZSSGL.EXE /D /A030 /R030 /$19.95 /I /KDC97C8877E90E4DA /LD9A4C239E763D306 /Hwww.yourwebsite.com /Myou@yourwebsite.com /NYour_Name_Here /OShareGuard /Pyourprogram.exe /Qwww.yourwebsite.com/register.html /TShareGuard_Demo "; /* === End ShareGuard Lock Parameters ============ */ /*-------------------------------------------------*/ /* Check the CRC Value of ZSSGLOCK.DLL to ensure */ /* that nobody has replaced it with a dummy module */ /*-------------------------------------------------*/ bShutdown = FALSE; // initialize the Shutdown to false if (CRC32FileCheck != NULL) hexresult = CRC32FileCheck(filename); else { MessageBox(0, "DLL not successfully loaded - application will terminate.", "ShareGuard Error",MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); bShutdown = TRUE; } myresult = (char *)malloc(9*sizeof(char)); // Room for 8 characters, plus null... myresult = hexresult; if(strcmp(hexanswer,myresult)!=0) { MessageBox(0, "CRC not valid for ZSSGLOCK.DLL - application will terminate.", "ShareGuard Error",MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); bShutdown = TRUE; } /* Do not free library until result has been tested */ if (CRC32FileCheck != NULL) FreeLibrary (hinstDLL); free(myresult); /*-------------------------------------------------*/ /* Check the reason code of the demo to see if it */ /* still a demo or production or has expired or... */ /* NOTE: Only reason code 0 is valid */ /*-------------------------------------------------*/ if (ShareGuardLock != NULL) reasoncode = ShareGuardLock(lockparms); else { MessageBox(0, "DLL not successfully loaded", "ShareGuard Error",MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); bShutdown = TRUE; } if(strcmp(rcanswer,myreasoncode)!=0) { MessageBox(0, "Reason code not not valid for ZSSGLOCK.DLL - application will terminate.", "ShareGuard Error",MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); bShutdown = TRUE; } /* Do not free library until result has been tested */ if (ShareGuardLock != NULL) FreeLibrary (hinstLockDLL); free(myreasoncode); return bShutdown; } /* Compare Strings Through Pointers */ int pstrcmp(p1, p2) char *p1, *p2; /* const void * for ANSI C */ { return strcmp(*(char **)p1, *(char **)p2); } /* === End ShareGuard Lock Subroutine ============ */