hello,
i am very new to vc++.i have the code. - #include "windows.h"
-
#include "stdafx.h"
-
-
// Need the following header files to access the MSI API
-
-
#include "msi.h"
-
#include "msiquery.h"
-
#pragma comment(lib, "msi.lib")
-
-
// Export the function so MSI can call it using undecorated C style name
-
extern "C" _declspec(dllexport) UINT __stdcall VerifyPID(MSIHANDLE hInstall);
-
-
-
// Private Function definitions
-
TCHAR* GetPIDValue(TCHAR*);
-
-
extern "C" UINT __stdcall VerifyPID(MSIHANDLE hInstall)
-
{
-
// Local variables
-
UINT nRetVal = 0;
-
UINT uiMsiRc;
-
TCHAR szPidKey[MAX_PATH];
-
TCHAR szSourceDir[MAX_PATH];
-
TCHAR* lpszPidValue;
-
DWORD dwBuffer;
-
-
// Get the source folder for the msi project
-
dwBuffer = sizeof(szSourceDir)/sizeof(TCHAR);
-
-
uiMsiRc = MsiGetProperty(hInstall, TEXT("SourceDir"), szSourceDir, &dwBuffer);
-
-
if (ERROR_SUCCESS != uiMsiRc)
-
{
-
MessageBox(NULL, "Not able to retrieve the SourceDir property. The setup may be corrupt. Please contact Technical Support.", "Setup Error", MB_OK | MB_ICONEXCLAMATION);
-
return 0;
-
}
-
-
// Call function to decrypt the PID to validate against from a file stored on setup media
-
lpszPidValue = GetPIDValue(szSourceDir);
-
-
// Get the PIDKEY property value entered by the user from the active msi
-
dwBuffer = sizeof(szPidKey)/sizeof(TCHAR);
-
-
uiMsiRc = MsiGetProperty(hInstall, TEXT("PIDKEY"), szPidKey, &dwBuffer);
-
-
if (ERROR_SUCCESS != uiMsiRc)
-
{
-
MessageBox(NULL, "Not able to retrieve PIDKEY property. The setup may be corrupt. Please contact Technical Support.", "Setup Error", MB_OK | MB_ICONEXCLAMATION);
-
return 0;
-
}
-
-
//Insert code to check PIDKEY here
-
int str = lstrcmp(szPidKey, lpszPidValue);
-
-
//If PIDKEY passes check
-
if (str == 0)
-
MsiSetProperty(hInstall, "PIDCHECK", "TRUE");
-
//If PIDKEY doesn't pass check
-
else
-
{
-
MsiSetProperty(hInstall, "PIDCHECK", "FALSE");
-
MessageBox(NULL, "Please enter the correct product registration code!", "Invalid Key", MB_OK | MB_ICONINFORMATION);
-
}
-
-
return 0;
-
}
-
-
// GetPIDValue is used to locate and decrypt a key file on the setup media
-
// that contains the PID string to validate against.
-
-
TCHAR* GetPIDValue(TCHAR* lpszSourceDir)
-
{
-
// lpszSourceDir contains the fully qualified path to the location where the setup is running.
-
// For example, suppose the msi is located on a CD in the folder "\Setup\MySetup.msi".
-
// The user is running the CD in the D: drive.
-
// lpszSourceDir will have a value of "D:\Setup\".
-
// Note that the trailing slash is included!
-
-
// TO DO: Concatenate key file path, example lpszSourceDir + "MyKeyFile.dat"
-
// TO DO: Read key file from source media
-
// TO DO: Code decryption algorithm for key file
-
// For this example, simply return a literal PID key of format <### - #######>
-
-
return "123 - 4567890";
-
}
how can i attach "MyKeyFile.dat" which i given in comment line.
thanks in advance,
0 4187 Sign in to post your reply or Sign up for a free account.
Similar topics
by: tom |
last post by:
Hi,
How do I get the serial number of the harddisk in .NET?
I want this to be the same number even if the user has
reformatted, so I do not want the volume serial number.
Thanx,
t
|
by: Klaus Bonadt |
last post by:
In order to protect software from being copied without licence, I would like
to use something like a key, which fits only to the current system. The
serial number of the CPU or the current...
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I...
|
by: Paul |
last post by:
Hi Guys,
I have written an application in Visual C#, I wish to add serial number
validation dll to the installer, how do I go about doing this.
Thanks in advance.
Paul Mathebula
|
by: Yavuz Bogazci |
last post by:
Hi, we are developing an winforms application for task management. We want
generate a serial number wich includes Username, Company Name and another
Information as String. How can i create from...
|
by: CJM |
last post by:
I'm working on my first Oracle DB, so bear with me...
I have a couple of validation routines which are both returning the same
result regardless of the inputs. One checks if a Serial No already...
|
by: Nebojsa4 |
last post by:
Hi.
First, sorry on my weak English to all.
Qusetion:
How to read (in VB) Manufacturer serial number of Hard disk drive?
Not volume/serial number of C:, D:, etc. partitons.
For reading...
|
by: sheperson |
last post by:
Hi,
I have been working for several months on a sofware and now it is
finished.
I have a problem now and it is this:
Because I live in a country which there is no copyright law in it
(Iran!!!!)....
|
by: 100grand |
last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one
product at a time, including the item number, the name of the product, the number of
units in stock, the price...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |