DLL编写+MFC调用程序
2010-04-16 22:04
211 查看
*******************************************************************
DLL编写
extern "C" _declspec(dllexport) int Test(int i)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return i+6;
}
*******************************************************************
调用test.DLL MFC程序
typedef int(_cdecl *Connect)(int i);
HINSTANCE hinstDLL=NULL;
hinstDLL=LoadLibrary("test.dll");
if (hinstDLL)
{
Connect Proc;
Proc = (Connect)GetProcAddress (hinstDLL,"Test"); //函数检索指定的动态链接库(DLL)中的输出库函数地址。
int iValue = Proc(m_i);
FreeLibrary(hinstDLL);
char * p = new char[10];
sprintf(p,"%d",iValue);
}
else
{
AfxMessageBox("没找到dll");
}
**************************************************************
DLL编写
extern "C" _declspec(dllexport) int Test(int i)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return i+6;
}
*******************************************************************
调用test.DLL MFC程序
typedef int(_cdecl *Connect)(int i);
HINSTANCE hinstDLL=NULL;
hinstDLL=LoadLibrary("test.dll");
if (hinstDLL)
{
Connect Proc;
Proc = (Connect)GetProcAddress (hinstDLL,"Test"); //函数检索指定的动态链接库(DLL)中的输出库函数地址。
int iValue = Proc(m_i);
FreeLibrary(hinstDLL);
char * p = new char[10];
sprintf(p,"%d",iValue);
}
else
{
AfxMessageBox("没找到dll");
}
**************************************************************
相关文章推荐
- 利用opencv编写dll,在另一个MFC程序中调用显示视频,dll可以用于没有装opencv的电脑中
- MFC程序调用MFC扩展DLL
- QT编写DLL给外部程序调用,提供VC/C#/C调用示例(含事件)
- [编程实例]Dev-C++编写动态调用dll杀进程的程序
- QT编写DLL给外部程序调用,提供VC/C#/C调用示例(含事件)good
- MFC调用QT编写的DLL动态库
- MFC:Win32-Dll及MFC-Dll编写调用
- MFC中调用C#编写的DLL
- VC dll程序的编写与调用 笔记
- C#调用MFC程序DLL库——MFC项目DLL生成问题、DLL引用链问题、DLL读取配置文件路径问题
- c#程序调用c++编写dll需要注意问题
- [VC]MFC程序动态调用plugin DLL的方式
- MFC 拓展链接库DLL的编写与调用
- QT编写DLL给外部程序调用,提供VC/C#/C调用示例(含事件)
- 编写一个小dll,供其他程序调用,新手勿喷
- C#调用C++程序编写的dll
- C#demo程序 调用自己编写的DLL
- 用MFC写对话框形式的DLL并用程序进行调用方法
- QT编写DLL给外部程序调用,提供VC/C#/C调用示例(含事件)
- c#程序调用c++编写dll需要注意问题