Advertisement
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: |
/*
* Copyright 2004 Caphyon LTD. All rights reserved.
*
* mailto: eng@caphyon.com
* http://www.caphyon.com
*
*/
// Serial Validation DLL.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#define PIDKEY_LENGTH 100
#define DIGIT(a) ((a) - '0')
BOOL APIENTRY DllMain(HANDLE /*hModule*/, DWORD /*ul_reason_for_call*/,
LPVOID /*lpReserved*/)
{
return TRUE;
}
#ifndef _DEBUG
BOOL WINAPI __DllMainCRTStartup(HINSTANCE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved)
{
return DllMain(hModule, ul_reason_for_call, lpReserved);
}
#endif
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 = ::MsiGetProperty(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
int x = DIGIT(szPidKey[0]);
int y = DIGIT(szPidKey[1]);
int z = DIGIT(szPidKey[2]);
int xyz = (x + y+ z);
int left = ((((xyz * xyz)+ 7) * 13 ));
//std::string Mystring = left;
//std::string left = Mystring.substr(0, 4);
int right = DIGIT(szPidKey[4]);
right = right & DIGIT(szPidKey[5]);
right = right & DIGIT(szPidKey[6]);
right = right & 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"), _T("Message"), MB_ICONSTOP);
serialValid = _T("FALSE");
}
res = ::MsiSetProperty(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;
}
|
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
|
Loading Advertisement... |
| Open Discussion |