用DLL中的函数在主对话框上画线



用DLL中的函数在主对话框上画线
 
用DLL中的函数在主对话框上画线
 


void CTest2Dlg::OnButton2()
{
typedef void(*pDrawLine)(CDC *pDC,CDialog *pDlg);

HINSTANCE hDLL;
pDrawLine DrawLine1;

hDLL=LoadLibrary("WBDLL.dll");//加载动态链接库MyDll.dll文件;

DrawLine1 = (pDrawLine)GetProcAddress(hDLL,"DrawLine");

CDC *pDC;
pDC = this->GetDC();
DrawLine1(pDC,this);

FreeLibrary(hDLL);//卸载MyDll.dll文件;

}




#include <AFXWIN.H>//CDC需要这个头文件


extern "C" __declspec(dllexport) void DrawLine(CDC *pDC,CDialog *pDlg);



void DrawLine(CDC *pDC,CDialog *pDlg)
{
pDC->MoveTo(0,0);
pDC->LineTo(200,200);
}




用DLL中的函数在主对话框上画线