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 4189 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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |