我用Win32 Console Application生成工程
Insert -> New Class -> CMyClass(Generic Class) -> 完成类的编写(用_tmain调试通过)
如何再创建一个工程,把CMyClass做成DLL 详细说明
Insert -> New Class -> CMyClass(Generic Class) -> 完成类的编写(用_tmain调试通过)
如何再创建一个工程,把CMyClass做成DLL 详细说明
解决方案 »
- 关于对话框
- ADO连接数据库
- 类似qq对话框靠边隐藏的效果
- 关于edit 换行问题(在线等待,急)
- 工程写的大了,有时想修改某一处,鼠标刚放下去,CPU就100%差不都1分钟,好象是工程在保存或读取什么似的 。。
- ㊣㊣为什么我写的一个基于socket的程序只要一调用WSAIoctl函数随即程序就会出现编译错误呢,link不上了,请知道的指点一二!㊣㊣
- 求教高手啊!!!!
- 内详,VC菜鸟问题!在线等,解决就给分
- P4 2G的CPU(升技主板),开机温度就到了45-50度,夏天使用中温度可以达到70-80度以至于死机,这算正常吗?(都有分)
- vc 的IDE问题
- 请问2002年在深圳报考高级程序员在什么地方报名? 报名时间 ? 有什么要求?
- 如何用odbc绑定DataGrid
给我你的MAIL,我写个例子给你!
附件不要超过1mb
Class AFX_EXT_CLASS youClass
{}
要求 先写好类的文件 再生成ddl工程把类的文件include进去
class AFX_EXT_CLASS CExDlg : public CDialog
{
// Construction
public:
CExDlg(CWnd* pParent = NULL); // standard constructor// Dialog Data
//{{AFX_DATA(CExDlg)
enum { IDD = IDD_DIALOG_EX };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CExDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected: // Generated message map functions
//{{AFX_MSG(CExDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};想加什么函数变量随你。cpp文件appwizard自动生成了,该怎么办就怎么办,跟别的mfc程序一样。建立一个mfc extend dll,名字叫cc(我起的)
cc.cpp:static AFX_EXTENSION_MODULE CcDLL = { NULL, NULL };extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("CC.DLL Initializing!\n");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(CcDLL, hInstance))
return 0; // Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result. new CDynLinkLibrary(CcDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("CC.DLL Terminating!\n");
// Terminate the library before destructors are called
AfxTermExtensionModule(CcDLL);
}
return 1; // ok
}cc.def:
; cc.def : Declares the module parameters for the DLL.LIBRARY "cc"
DESCRIPTION 'cc Windows Dynamic Link Library'EXPORTS
; Explicit exports can go here so build,ok,get cc.dll。如何调用dll中的类呐?我做了一个例程invokedll,在你想使用CExDlg的类头文件中#include "ExDlg.h"(注意不必把这个文件加入工程),然后就可以象使用自己当前工程中的某个类一样使用它。
invokedll.cpp:
........
#include "ExDlg.h"
..........BOOL CinvokedllApp::InitInstance()
{..........if (!ProcessShellCommand(cmdInfo))
return FALSE; // The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow(); CExDlg dlg;
dlg.DoModal();..........
}
就这么简单,我都不大相信:)