请教LoadLibrary使用方法!
HINSTANCE HInst = LoadLibrary("list.dll");
if(HInst == NULL)
{
cout<<"xxxxxxxxxxxxxxx!\n"<<endl;
return 0;
}
typedef CList* (*create)();
create c;
c = (create)GetProcAddress(HInst,"CreateClist");
if(c == NULL)
{
cout<<"create list failed!\n";
return 0;
}
CList* mylist = c();
if (NULL != mylist)
{
cout << "list construct." << endl;
}
mylist->Insert(3);
我使用如上方法调用LoadLibary函数,成功返回了list类型的实例对象mylist,但是在调用其方法的时候失败!
mylist->Insert(3);
main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall CList::Insert(int)" (__imp_?Insert@CList@@QAE_NH@Z)
Debug/list_dll_test.exe : fatal error LNK1120: 1 unresolved externals
头文件中
extern "C" LIST_API CList* CreateClist();函数用于创建实例对象
LIST_API CList* CreateClist()
{
CList *mylist = new CList;
return mylist;
}
请问这是什么原因?是不是因为C与C++函数名重载相关的原因?是不是这样就表示不能通过loadlibary的方法调用dll中的类?