下面是dll的导出函数,请问像MFC中的这些函数我改怎么调用使dll在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 ;
}
//
}
} 展开
1个回答
展开全部
在程序中LoadLibrary然后GetProcAddress,带入函数原型后调用即可。
如文件名是a.dll的话,以调用DrawEllipse为例
HMOUDLE hMoudle = LoadLibrary("a.dll");
typedef void (*FUNC_DRAWELLIPSE)(CRect rect ,CDC *p);
FUNC_DRAWELLIPSE func_DrawEllipse = (FUNC_DRAWELLIPSE) GetProcAddress(hMoudle, "DrawEllipse");
func_DrawEllipse(带入参数);
FreeLibrary(hModule);
如文件名是a.dll的话,以调用DrawEllipse为例
HMOUDLE hMoudle = LoadLibrary("a.dll");
typedef void (*FUNC_DRAWELLIPSE)(CRect rect ,CDC *p);
FUNC_DRAWELLIPSE func_DrawEllipse = (FUNC_DRAWELLIPSE) GetProcAddress(hMoudle, "DrawEllipse");
func_DrawEllipse(带入参数);
FreeLibrary(hModule);
更多追问追答
追问
这个参数还是跟原来的一样吗?我要把这些函数全部放在启动项调用,那又该怎么调用呢?拜托大侠说具体一点,谢谢了。
追答
和原来的参数一样
放在启动项调用是指?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询