gpt4 book ai didi

c++ - Advanced Installer 串行验证 DLL

转载 作者:行者123 更新时间:2023-11-28 07:32:57 24 4
gpt4 key购买 nike

我正在 Advanced Installer 10.2 中开发一个安装程序项目。我发现我可以使用 DLL 进行串行验证然后我发现 this他们网站上的资源。

我成功地构建了那个 DLL,这是我的代码:

//SerialValidationLib.cpp : 定义 DLL 应用程序的导出函数。//

#include "stdafx.h"
#include "SerialValidationLib.h"
#include <Msi.h>
#include <MsiQuery.h>
#include <MsiDefs.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

HMODULE hModule = ::GetModuleHandle(NULL);

if (hModule != NULL)
{
// initialize MFC and print and error on failure
if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
}
}
else
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
nRetCode = 1;
}

return nRetCode;
}



UINT __stdcall ValidateSerial_Sample(MSIHANDLE hInstall)
{
TCHAR szPidKey[256];
DWORD dwLen = sizeof(szPidKey)/sizeof(szPidKey[0]);
//retrive 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 = false;
//validate the text from szPidKey according to your algorithm
//put the result in snIsValid
TCHAR * serialValid;
if(snIsValid)
serialValid = _T("TRUE");
else
{
//eventually say something to the user
MessageBox(0, _T("Serial invalid!"), _T("Message"), MB_ICONSTOP);
serialValid = _T("FALSE");
}
res = MsiSetProperty(hInstall, _T("SERIAL_VALIDATION"), serialValid);
if(res != ERROR_SUCCESS)
{
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;
}

我也将它导入到 Advanced Installer,看这里:

enter image description here

但是当我运行安装程序并尝试继续安装时,在串行插入点之后,我收到此错误消息:

enter image description here

我的错误在哪里?有人知道这方面的好教程吗?我在互联网上搜索,但没有任何帮助...

最佳答案

你可能有两个问题:

  • 要么您输入了方法名称,而不是从 Advanced Installer 加载的组合中选择它。在这种情况下,安装程序无法从 DLL 调用该方法,因为它找不到它。

  • 或者,您的代码有问题,在这种情况下,您需要调试它,就像您对正常的自定义操作所做的那样,从 VS 附加(添加一个带有断点的消息框)。

关于c++ - Advanced Installer 串行验证 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17296490/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com