943,539 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1578
  • C++ RSS
Dec 18th, 2007
0

Help regarding MSI Serial Key Validation

Expand Post »
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.
C++ Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Exelio is offline Offline
57 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Compare in templatized data structure
Next Thread in C++ Forum Timeline: Word break and line break in Rich Edit Control





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC