Help regarding MSI Serial Key Validation

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2006
Posts: 57
Reputation: Exelio is an unknown quantity at this point 
Solved Threads: 0
Exelio Exelio is offline Offline
Junior Poster in Training

Help regarding MSI Serial Key Validation

 
0
  #1
Dec 18th, 2007
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.
  1. UINT __stdcall ValidateSerial(MSIHANDLE hInstall)
  2. {
  3. TCHAR szPidKey[PIDKEY_LENGTH];
  4. DWORD dwLen = sizeof(szPidKey) / sizeof(szPidKey[0]);
  5.  
  6. ///retrieve the text entered by the user
  7. UINT res = MsiGetPropertyA(hInstall, _T("PIDKEY"), szPidKey, &dwLen);
  8. if(res != ERROR_SUCCESS)
  9. {
  10. //fail the installation
  11. return 1;
  12. }
  13.  
  14. bool snIsValid = true;
  15. //validate the text from szPidKey according to your algorithm
  16. //put the result in snIsValid
  17.  
  18. //the template we use is <###-####> = ; # digit between 0 and 9
  19. //the algorithm is very simple (XY * Z + 7) * 13 = ABCD / 2
  20. int xy = DIGIT(szPidKey[0]) * 10 + DIGIT(szPidKey[1]);
  21. int z = DIGIT(szPidKey[2]);
  22. int left = ((xy * z + 7) * 13 ) * 2;
  23. int right = DIGIT(szPidKey[4]);
  24. right = right * 10 + DIGIT(szPidKey[5]);
  25. right = right * 10 + DIGIT(szPidKey[6]);
  26. right = right * 10 + DIGIT(szPidKey[7]);
  27. snIsValid = (left != 0) && (right != 0) && (left == right);
  28.  
  29. TCHAR * serialValid = NULL;
  30. if(snIsValid)
  31. serialValid = _T("TRUE");
  32. else
  33. {
  34. //eventually say something to the user
  35. ::MessageBox(0, _T("Invalid Serial Number"), _T("Message"), MB_ICONSTOP);
  36.  
  37. serialValid = _T("FALSE");
  38. }
  39.  
  40. res = MsiSetPropertyA(hInstall, _T("SERIAL_VALIDATION"), serialValid);
  41. if(res != ERROR_SUCCESS)
  42. {
  43. //fail the installation
  44. return 1;
  45. }
  46.  
  47. //the validation succeeded - even the serial is wrong
  48. //if the SERIAL_VALIDATION was set to FALSE the installation will not continue
  49. return 0;
  50. }
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

exelio
Last edited by Ancient Dragon; Dec 18th, 2007 at 4:49 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC