VS2010中 C++创建DLL图解
来源:互联网 发布:东亚文化圈知乎 编辑:程序博客网 时间:2024/05/21 15:07
一、DLL的创建
创建项目: Win32->Win32项目,名称:MyDLL
选择DLL (D) ->完成.
1、新建头文件testdll.h
testdll.h代码如下:
#ifndef TestDll_H_
#define TestDll_H_
#ifdef MYLIBDLL
#define MYLIBDLL extern "C" _declspec(dllimport)
#else
#define MYLIBDLL extern "C" _declspec(dllexport)
#endif
MYLIBDLL int Add(int plus1, int plus2);
//You can also write like this:
//extern "C" {
//_declspec(dllexport) int Add(int plus1, int plus2);
//};
#endif
2、新建源文件testdll.cpp
testdll.cpp代码如下:
#include "stdafx.h"
#include "testdll.h"
#include <iostream>
using namespace std;
int Add(int plus1, int plus2)
{
int add_result = plus1 + plus2;
return add_result;
}
3、新建模块定义文件mydll.def
mydll.def代码如下:
LIBRARY "MyDLL"
EXPORTS
Add @1
4、vs2010自动创建dllmain.cpp文件,它定义了DLL 应用程序的入口点。
dllmain.cpp代码如下:
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
最后,编译生成MyDLL.dll文件和MyDLL.lib文件。
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解.
- VS2010中 C++创建DLL图解.
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- C++ VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中 C++创建DLL图解
- VS2010中创建DLL
- VS2010 C++创建、调用DLL图解
- 异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG)
- onvif研究总结
- 通过Ajax修改PHP全局变量$_POST
- 异步Socket (.net)
- IE8 调试ocx dll 无法进入断点
- VS2010中 C++创建DLL图解
- Android JNI开发入门之一
- MapReduce:一个巨大的倒退
- Magento全局配置文件的一些理解
- Windows 8预览发布版完成 即将发布
- Struts1框架
- php输入流php://input 使用详解
- 程序员的幽默 .
- 分享百度网盘邀请码十个