DLL导出类
来源:互联网 发布:python编程思想 编辑:程序博客网 时间:2024/06/14 01:26
DLL头文件:
DLL实现文件:
应用程序调用DLL
#ifndef _DLL_SAMPLE_H
#define _DLL_SAMPLE_H
// 通过宏来控制是导入还是导出
#ifdef _DLL_SAMPLE
#define DLL_SAMPLE_API __declspec(dllexport)
#else
#define DLL_SAMPLE_API __declspec(dllimport)
#endif
// 导出/导入变量声明
class DLL_SAMPLE_API DLLClass
{
public:
void Show();
};
#undef DLL_SAMPLE_API
#endif
#define _DLL_SAMPLE_H
// 通过宏来控制是导入还是导出
#ifdef _DLL_SAMPLE
#define DLL_SAMPLE_API __declspec(dllexport)
#else
#define DLL_SAMPLE_API __declspec(dllimport)
#endif
// 导出/导入变量声明
class DLL_SAMPLE_API DLLClass
{
public:
void Show();
};
#undef DLL_SAMPLE_API
#endif
DLL实现文件:
#include "stdafx.h"
#define _DLL_SAMPLE
#ifndef _DLL_SAMPLE_H
#include "DLLSample.h"
#endif
#include "stdio.h"
//APIENTRY声明DLL函数入口点
BOOL APIENTRY DllMain(HANDLE 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;
}
void DLLClass::Show()
{
printf("DLLClass show!");
}
#define _DLL_SAMPLE
#ifndef _DLL_SAMPLE_H
#include "DLLSample.h"
#endif
#include "stdio.h"
//APIENTRY声明DLL函数入口点
BOOL APIENTRY DllMain(HANDLE 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;
}
void DLLClass::Show()
{
printf("DLLClass show!");
}
应用程序调用DLL
#include "DLLSample.h"
#pragma comment(lib,"DLLSample.lib")
int main(int argc, char *argv[])
{
DLLClass dc;
dc.Show();
return 0;
}
#pragma comment(lib,"DLLSample.lib")
int main(int argc, char *argv[])
{
DLLClass dc;
dc.Show();
return 0;
}
0 0
- DLL概念,DLL导出类
- DLL导出类问题
- DLL 导出类
- 【zz】DLL 导出类
- dll导出stl类
- MFC DLL导出类
- DLL导出类
- dll导出类
- dll导出类
- dll导出类
- DLL导出类
- DLL 导出类
- C++ DLL导出类
- dll之导出类
- MFC DLL导出类
- DLL导出类
- DLL 导出C++ 类
- DLL 导出类
- Android 部分页面乱码的解决
- Secure CRT常用Linux命令以及快捷键
- laravel 基础教程 —— 验证
- 哈希冲突的解决方法
- 遇到一个C语言的神奇问题
- DLL导出类
- Java网络通信之HttpUrlConnection
- 部分和问题
- 8.Linux系统的目录结构
- java中方法的参数传递的是什么?
- 多重ScrollView、HorizontalScrollView、ListView嵌套的死磕!
- android中内存调试信息的解读
- C++四本有用书
- 【错误解析】关于ORA-4025错误