调试了半个晚上,终于OK~
extern "C" __declspec (dllexport) void warn(int j) { CString str; str.Format("%d",j); AfxMessageBox("test!_"+str); } extern "C" __declspec (dllexport) int ot(int j) { return j; } extern "C" __declspec (dllexport) void hello() { AfxMessageBox(""); } |
HINSTANCE hd; static int j=0; j++; typedef int(FUNA)(int); typedef int(FUNB)(int); typedef void(FUNC)(void); FUNA* pa; FUNB *pb; FUNC *pc; hd=LoadLibrary("dll1.dll"); pa=(FUNA*)GetProcAddress(hd,"ot"); if (!pa) AfxMessageBox("failed in ot"); else j=(*pa)(j); pb=(FUNB *)GetProcAddress(hd,"warn"); if (!pb) AfxMessageBox("failed in warn"); else (*pb)(j); pc=(FUNC *)GetProcAddress(hd,"hello"); if (!pc) AfxMessageBox("failed in hello"); else (*pc)(); FreeLibrary(hd); |