CInfoQuerySheet::CInfoQuerySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
m_psh.dwFlags |= PSH_NOAPPLYNOW; // Lose the Apply Now button
AddPage(&m_Page1);
HINSTANCE hDllInst = ::LoadLibrary("ProQueryRoute.dll");
if(hDllInst)
{
typedef DWORD (WINAPI *MYFUNC)(CInfoQuerySheet*);
MYFUNC MyFuntionNameAlias = NULL;
MyFuntionNameAlias = (MYFUNC)GetProcAddress(hDllInst,"GetDlgQueryRoute");
if(MyFuntionNameAlias)
{
MyFuntionNameAlias(this);
} }ProQueryRoute.dll这个里实际上是又添加了一页。不是DLL本身问题,空函数也是会报错的,是不是加载有问题呢?谢谢诸位了
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
m_psh.dwFlags |= PSH_NOAPPLYNOW; // Lose the Apply Now button
AddPage(&m_Page1);
HINSTANCE hDllInst = ::LoadLibrary("ProQueryRoute.dll");
if(hDllInst)
{
typedef DWORD (WINAPI *MYFUNC)(CInfoQuerySheet*);
MYFUNC MyFuntionNameAlias = NULL;
MyFuntionNameAlias = (MYFUNC)GetProcAddress(hDllInst,"GetDlgQueryRoute");
if(MyFuntionNameAlias)
{
MyFuntionNameAlias(this);
} }ProQueryRoute.dll这个里实际上是又添加了一页。不是DLL本身问题,空函数也是会报错的,是不是加载有问题呢?谢谢诸位了
this->AddPage( &m_PropertyPage )我的代码是:
DLL中
extern "C"__declspec(dllexport) CPropertyPage* Ex22cGetSheet2()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CSheet2* dlg;
dlg = new CSheet2;
ASSERT_KINDOF(CPropertyPage,dlg);
return (CPropertyPage*)dlg;
}
主程序中:
extern "C"__declspec(dllimport) CPropertyPage* Ex22cGetSheet2();
CSheet::CSheet()
:CPropertySheet("系统设置", NULL, 0)
{
AddPage(Ex22cGetSheet2());
}
如果DLL是由DEBUG生成的则主程序不管是DEBUG还是RELEASE都可以正常运行,但如果DLL是由RELEASE生成的则在主程序为DEBUG时出错:
void CPropertySheet::AddPage(CPropertyPage* pPage)
{
ASSERT_VALID(this);
ASSERT(pPage != NULL);
ASSERT_KINDOF(CPropertyPage, pPage);//这里出错
ASSERT_VALID(pPage);
主程序为RELEASE则完全正常.