Help regarding MSI serial key validation
-
hi all, I am using ORCA to validate the product key in C# 2005 windows application. i am using the following C++ code in a dll to be added to the MSI for validation. UINT __stdcall ValidateSerial(MSIHANDLE hInstall) { TCHAR szPidKey[PIDKEY_LENGTH]; DWORD dwLen = sizeof(szPidKey) / sizeof(szPidKey[0]); ///retrieve the text entered by the user UINT res = MsiGetPropertyA(hInstall, _T("PIDKEY"), szPidKey, &dwLen); if(res != ERROR_SUCCESS) { //fail the installation return 1; } bool snIsValid = true; //validate the text from szPidKey according to your algorithm //put the result in snIsValid //the template we use is <###-####> = ; # digit between 0 and 9 //the algorithm is very simple (XY * Z + 7) * 13 = ABCD / 2 int xy = DIGIT(szPidKey[0]) * 10 + DIGIT(szPidKey[1]); int z = DIGIT(szPidKey[2]); int left = ((xy * z + 7) * 13 ) * 2; int right = DIGIT(szPidKey[4]); right = right * 10 + DIGIT(szPidKey[5]); right = right * 10 + DIGIT(szPidKey[6]); right = right * 10 + DIGIT(szPidKey[7]); snIsValid = (left != 0) && (right != 0) && (left == right); TCHAR * serialValid = NULL; if(snIsValid) serialValid = _T("TRUE"); else { //eventually say something to the user ::MessageBox(0, _T("Invalid Serial Number"), _T("Message"), MB_ICONSTOP); serialValid = _T("FALSE"); } res = MsiSetPropertyA(hInstall, _T("SERIAL_VALIDATION"), serialValid); if(res != ERROR_SUCCESS) { //fail the installation return 1; } //the validation succeeded - even the serial is wrong //if the SERIAL_VALIDATION was set to FALSE the installation will not continue return 0; } but when i execute the above code, i am getting the following error. error LNK2019: unresolved external symbol _MsiSetPropertyA@12 referenced in function "unsigned int __stdcall ValidateSerial(unsigned long)" (?ValidateSerial@@YGIK@Z) CustomAction.obj i have included and I am a beginner in VC++ and could anybody help me with some suggestions Thanks in advance.:) Regards Anuradha