这是dll的导出函数,是一个mfc的项目,在exe中我该怎么调用,使之运行起来?求救。
extern"C"__declspec(dllexport)voidDrawEllipse(CRectrect,CDC*p){CBrushbrush;brush.Crea...
extern "C" __declspec(dllexport) void DrawEllipse ( CRect rect ,CDC *p )
{
CBrush brush;
brush.CreateSolidBrush(RGB(0,0,255));
p->SelectObject(&brush);
p->Ellipse(&rect);
}
extern "C" __declspec(dllexport) HWND ShowMainFormDlg (CWnd *pParenWnd,void * pMaster)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;由AfxGetStaticModuleState返回的正确的模块状态,得到正确的句柄。
if (g_MainFrm == NULL)
{
g_MainFrm = new CMainFormDlg();
g_MainFrm->m_pMaster =(IUnknown *) pMaster;
g_MainFrm->Create(CMainFormDlg::IDD ,NULL);
g_MainFrm->SetParent(pParenWnd);
g_MainFrm->ShowWindow(SW_SHOW);
g_MainFrm->SetFocus();
g_MainFrm->m_ParentHwnd = pParenWnd->m_hWnd;
return g_MainFrm ->m_hWnd;
}
else
{
g_MainFrm->LockTrading();
}
return g_MainFrm ->m_hWnd;
}
extern "C" __declspec(dllexport) void DestroyMainFormDlg ()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;
if (g_MainFrm != NULL)
{
g_MainFrm->DestroySubWndDlg(NULL);
g_MainFrm->DestroyWindow();
delete g_MainFrm;
g_MainFrm = NULL;
}
}
extern "C" __declspec(dllexport) void UserLogin()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;
if (g_MainFrm != NULL)
{
if (strlen(g_ClientUserInfo.pUserLoginName) == 0)
{
g_MainFrm->UserLogin();
g_MainFrm->m_LockTimeCount = 0;
}
else
{
g_MainFrm->m_LockTimeCount = 0;
//g_MainFrm->LockTrading();
}
}
}
extern "C" __declspec(dllexport)void QuickOrder(int nMode, const char *pCode,const char *pCodeName,double dbPrice,int nLotSize)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;
if (g_MainFrm != NULL)
{
g_MainFrm->QuickOrder(nMode,pCode,pCodeName,dbPrice,nLotSize);
}
}
extern "C" __declspec(dllexport)void LockedTrading()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;
if (g_MainFrm != NULL)
{
if (g_SetSystemParam.AutoTradeLock)
{
g_MainFrm->LockTrading();
}
else
{
g_MainFrm->m_LockTimeCount = 30 ;
}
//
}。
} 展开
{
CBrush brush;
brush.CreateSolidBrush(RGB(0,0,255));
p->SelectObject(&brush);
p->Ellipse(&rect);
}
extern "C" __declspec(dllexport) HWND ShowMainFormDlg (CWnd *pParenWnd,void * pMaster)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;由AfxGetStaticModuleState返回的正确的模块状态,得到正确的句柄。
if (g_MainFrm == NULL)
{
g_MainFrm = new CMainFormDlg();
g_MainFrm->m_pMaster =(IUnknown *) pMaster;
g_MainFrm->Create(CMainFormDlg::IDD ,NULL);
g_MainFrm->SetParent(pParenWnd);
g_MainFrm->ShowWindow(SW_SHOW);
g_MainFrm->SetFocus();
g_MainFrm->m_ParentHwnd = pParenWnd->m_hWnd;
return g_MainFrm ->m_hWnd;
}
else
{
g_MainFrm->LockTrading();
}
return g_MainFrm ->m_hWnd;
}
extern "C" __declspec(dllexport) void DestroyMainFormDlg ()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;
if (g_MainFrm != NULL)
{
g_MainFrm->DestroySubWndDlg(NULL);
g_MainFrm->DestroyWindow();
delete g_MainFrm;
g_MainFrm = NULL;
}
}
extern "C" __declspec(dllexport) void UserLogin()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;
if (g_MainFrm != NULL)
{
if (strlen(g_ClientUserInfo.pUserLoginName) == 0)
{
g_MainFrm->UserLogin();
g_MainFrm->m_LockTimeCount = 0;
}
else
{
g_MainFrm->m_LockTimeCount = 0;
//g_MainFrm->LockTrading();
}
}
}
extern "C" __declspec(dllexport)void QuickOrder(int nMode, const char *pCode,const char *pCodeName,double dbPrice,int nLotSize)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;
if (g_MainFrm != NULL)
{
g_MainFrm->QuickOrder(nMode,pCode,pCodeName,dbPrice,nLotSize);
}
}
extern "C" __declspec(dllexport)void LockedTrading()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());//;
if (g_MainFrm != NULL)
{
if (g_SetSystemParam.AutoTradeLock)
{
g_MainFrm->LockTrading();
}
else
{
g_MainFrm->m_LockTimeCount = 30 ;
}
//
}。
} 展开
展开全部
抱歉那时候没来得及回答你的追问,
具体的例子就是定义一个头文件比如a.h
里面写上extern FUNC_DRAWELLIPSE func_DrawEllipse;
在需要用到的地方include上,然后在你InitInstance的地方,在函数外声明一个FUNC_DRAWELLIPSE func_DrawEllipse;
然后在InitInstance内LoadLibrary, GetProcAddress
然后其他文件中直接选择调用func_DrawEllipse(...)即可.
具体的例子就是定义一个头文件比如a.h
里面写上extern FUNC_DRAWELLIPSE func_DrawEllipse;
在需要用到的地方include上,然后在你InitInstance的地方,在函数外声明一个FUNC_DRAWELLIPSE func_DrawEllipse;
然后在InitInstance内LoadLibrary, GetProcAddress
然后其他文件中直接选择调用func_DrawEllipse(...)即可.
更多追问追答
追问
嗯,可是我遇到一个新问题,就是你说函数参数还是和原来的一样,可是行通,你帮我看一下,我用this指针也用不了。typedef HWND (*ShowDlg) (CWnd *pParenWnd,void * pMaster);
BOOL CGuoduApp::InitInstance()
{ HINSTANCE hdll=LoadLibrary("..\\debug\\TradeModule.dll");
ShowDlg fun_ShowDlg=(ShowDlg)GetProcAddress(hdll,"ShowMainFormDlg");
(*fun_ShowDlg)(this,NULL);
FreeLibrary(hdll);}
追答
这里不能用this了..这里的类对象是WinApp不是Dialog..
所以需要由AfxGetApp()->m_pMainWnd->m_hWnd来代替this..
参考资料: http://zhidao.baidu.com/question/312061125.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询