sir, Actually u gave me the nice way for serial key validation.
But actually i am doing this first time and this is my first project i am not going to understand the some concepts in detail would u help me?.
i do my work according to the http://sudag.blogspot.com/
in this in comment 3 they are suggested to use the Validate a Serial Number During Installation of your Windows Installer (MSI) Using Orca this link so i do the as they suggested.
1.download
2.Install
3.click start then orca
4.open orca
then
I – Set up your VSI project
- Create an empty installer project with VSI.
- Add a Customer Information dialog box to the user interface. Do not change the default properties for the dialog box.
- Build the project.
1. Create a custom action DLL that contains you serial number validation logic
(I created the dll)
2 . I use the same code that they suggested.but i got the errors at some lines so i comment the some line& my function is like:_
UINT __stdcall VerifyPID(MSIHANDLE hInstall)
{
// Local variables
UINT nRetVal = 0;
UINT uiMsiRc;
TCHAR szPidKey[MAX_PATH];
DWORD dwBuffer;
// First Step - Get the PIDKEY property
//uiMsiRc = MsiGetProperty(hInstall, TEXT("PIDKEY"), szPidKey, &dwBuffer);
if (ERROR_SUCCESS != uiMsiRc)
{
// MessageBox(NULL, "PIDKEY", "Not able to retrieve PIDKEY property", MB_OK MB_ICONEXCLAMATION);
return 0;
}
//Insert code to check PIDKEY here
// int str = lstrcmp(szPidKey, "123 -4567890");
int str;
//If PIDKEY passes check
/* if (str == 0)
// MsiSetProperty(hInstall, "PIDCHECK", "TRUE");
//If PIDKEY doesn't pass check
else
{
MsiSetProperty(hInstall, "PIDCHECK", "FALSE");
wsprintf(szText, "Please enter the correct code");
MessageBox(NULL, szText, "PIDCHECK", MB_OK MB_ICONINFORMATION);
}*/
return 0;
}
Error 2 error C3861: 'MsiGetProperty': identifier not found f:\astika\testdll\testdll.cpp
30 testdll is got at this line
uiMsiRc = MsiGetProperty(hInstall, TEXT("PIDKEY"), szPidKey, &dwBuffer);
Error 3 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR' f:\astika\testdll\testdll.cpp34 testdll
is got at each Messagebox
so can u resolve it.
Error 2 error C2664: 'lstrcmpW' : cannot convert parameter 2 from 'const char [13]' to 'LPCWSTR' f:\astika\testdll\testdll.cpp39 testdll
is got at line int str = lstrcmp(szPidKey, "123 -4567890");
please help me.
i also the problems in 3,4,5 i can't understand what this steps means:
- On the Tools menu, click the Options Directories tab in your DLL project, and then add the path to the Windows Installer SDK's Include and Lib directories.
- In the Project Settings dialog box, add msi.lib to the library list.
- Then, either use a .DEF file or the __declspec(dllimport) attribute to export the DLL functions.
Sam HobbsPosted Feb 5, 2011, 3:22 PM
Orca is a tool for editing MSI files (databases). It does nothing more than make it easier for us to edit the database.
It appears that you are encountering errors in your unmanaged DLL developed using C++. To use a regular DLL in C++, you need to #include the relevant header, then ensure that the relevant library is listed for the project and that the location of the library is also speified. The errors for MessageBoxW and lstrcmpW are also due to missing #includes. The instructions for providing the the Windows Installer SDK's Include and Lib directories and for adding msi.lib to the library list will help.
As for using either a .DEF file or the __declspec(dllimport) attribute to export the DLL functions, ignore the .DEF file option; please use the __declspec(dllimport) attribute to export the DLL functions. In fact, if you were to create the DLL project with the option to generate code, the __declspec(dllimport) attribute will already be in the source code.
You just need to learn the basics of C++ programmming and DLLs. If you were adequately familiar with C++ it would be easy to learn about DLLs but I get the impression it would help you most if you to spend time reading a good book so you understand the basics. You absolutely must understand about headers (#includes); then it will help you to understand about DLLs in the sense of DLLs have functions that must be defined, typically in headers, and that the compiler needs to know what library (lib) files to look in for the functions and what directory to look in for the library. It will also help you to understand how __declspec(dllimport) and __declspec(dllexport) work.
Suthish NairPosted Feb 5, 2011, 4:51 AM