积极答复者
DLL 中类的使用

问题
-
我创建了一个dll 里面自己添加了一个对话框的类Cmain怎样显示调用它
我自己用了一种方法就是在原来的类的成员函数aa()中用创建它int CSecretApp::aa()
{
Cmain *main = new Cmain();
main->Create(IDD_DIALOG1);
main->ShowWindow(SW_SHOW);return 0;
}不过在另一个程序中调用 aa()函数的使用 出现了错误
unresolved external symbol "public: __thiscall Cmain::Cmain(class CWnd *)" (??0Cmain@@QAE@PAVCWnd@@@Z)
这个要怎么解决 最好提供直接使用dll中类的方法
C++
答案
-
1 对于其他app调用这个函数,需要添加
declspec(dllexport) int CSecretApp::aa()
{
Cmain *main = new Cmain();
main->Create(IDD_DIALOG1);
main->ShowWindow(SW_SHOW);return 0;
}2 由于DLL拥有自己的资源,所以其他app调用的时候需要在使用DLL资源前进行资源切换。
declspec(dllexport) int CSecretApp::aa()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());Cmain *main = new Cmain();
main->Create(IDD_DIALOG1);
main->ShowWindow(SW_SHOW);return 0;
}
麻烦把正确答案设为解答。
全部回复
-
1 对于其他app调用这个函数,需要添加
declspec(dllexport) int CSecretApp::aa()
{
Cmain *main = new Cmain();
main->Create(IDD_DIALOG1);
main->ShowWindow(SW_SHOW);return 0;
}2 由于DLL拥有自己的资源,所以其他app调用的时候需要在使用DLL资源前进行资源切换。
declspec(dllexport) int CSecretApp::aa()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());Cmain *main = new Cmain();
main->Create(IDD_DIALOG1);
main->ShowWindow(SW_SHOW);return 0;
}
麻烦把正确答案设为解答。