Hi All,
I have developed a VC+ dll file which provides a product key for my msi setup file. This VC++ dll work fine together with my setup file. but,
my problem is, i have given a message box inside the dll for showing error message while an invalid key is entered. but the messagebox is not shown as modal dialog. i must want to show this as modal dialog.
in my VC++ method i have passed the MSIHANDLE from the msi file.
how can i change the message as modal dialog?
my code is:
#include "windows.h"
#include "msi.h"
#include "msiquery.h "
extern "C" _declspec(dllex port) UINT __stdcall VerifyPID(MSIHA NDLE hInstall);
TCHAR* GetPIDValue(TCH AR*);
extern "C" UINT __stdcall VerifyPID(MSIHA NDLE hInstall)
{
UINT nRetVal = 0;
UINT uiMsiRc;
TCHAR szPidKey[MAX_PATH];
TCHAR szSourceDir[MAX_PATH];
TCHAR* lpszPidValue;
DWORD dwBuffer;
dwBuffer = sizeof(szSource Dir)/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_ICONEXCLAMAT ION);
return 0;
}
lpszPidValue = GetPIDValue(szS ourceDir);
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_ICONEXCLAMAT ION);
return 0;
}
int str = lstrcmp(szPidKe y, lpszPidValue);
if (str == 0)
MsiSetProperty( hInstall, "PIDCHECK", "TRUE");
else
{
MsiSetProperty( hInstall, "PIDCHECK", "FALSE");
MessageBox(NULL ,"Please enter the correct product registration code!", "Invalid Key", MB_OK | MB_ICONINFORMAT ION);
}
return 0;
}
TCHAR* GetPIDValue(TCH AR* lpszSourceDir)
{
return "123-456-789";
}
Please help to resolve it.
Thanks in advance.
Regards,
Dhanasekaran. G
I have developed a VC+ dll file which provides a product key for my msi setup file. This VC++ dll work fine together with my setup file. but,
my problem is, i have given a message box inside the dll for showing error message while an invalid key is entered. but the messagebox is not shown as modal dialog. i must want to show this as modal dialog.
in my VC++ method i have passed the MSIHANDLE from the msi file.
how can i change the message as modal dialog?
my code is:
#include "windows.h"
#include "msi.h"
#include "msiquery.h "
extern "C" _declspec(dllex port) UINT __stdcall VerifyPID(MSIHA NDLE hInstall);
TCHAR* GetPIDValue(TCH AR*);
extern "C" UINT __stdcall VerifyPID(MSIHA NDLE hInstall)
{
UINT nRetVal = 0;
UINT uiMsiRc;
TCHAR szPidKey[MAX_PATH];
TCHAR szSourceDir[MAX_PATH];
TCHAR* lpszPidValue;
DWORD dwBuffer;
dwBuffer = sizeof(szSource Dir)/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_ICONEXCLAMAT ION);
return 0;
}
lpszPidValue = GetPIDValue(szS ourceDir);
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_ICONEXCLAMAT ION);
return 0;
}
int str = lstrcmp(szPidKe y, lpszPidValue);
if (str == 0)
MsiSetProperty( hInstall, "PIDCHECK", "TRUE");
else
{
MsiSetProperty( hInstall, "PIDCHECK", "FALSE");
MessageBox(NULL ,"Please enter the correct product registration code!", "Invalid Key", MB_OK | MB_ICONINFORMAT ION);
}
return 0;
}
TCHAR* GetPIDValue(TCH AR* lpszSourceDir)
{
return "123-456-789";
}
Please help to resolve it.
Thanks in advance.
Regards,
Dhanasekaran. G
Comment