Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help regarding MSI serial key validation

Help regarding MSI serial key validation

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++algorithmsquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anu81
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups