DLL导出
来源:互联网 发布:mysql恢复删除的数据 编辑:程序博客网 时间:2024/06/05 16:43
DLL导出
DllMain 类似于main函数或者winmain等入口函数,当加载、卸载、线程启动、线程终止时会调用,可在此申请资源或清理资源等。
DLL可以配合头文件和lib使用,或者使用LoadLibrary+GetProcAddress动态加载。
代码:
DLL:
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: OutputDebugStringA("DLL_PROCESS_ATTACH"); break; case DLL_THREAD_ATTACH: OutputDebugStringA("DLL_THREAD_ATTACH"); break; case DLL_THREAD_DETACH: OutputDebugStringA("DLL_THREAD_DETACH"); break; case DLL_PROCESS_DETACH: OutputDebugStringA("DLL_PROCESS_DETACH"); break; } return TRUE;}
head.h 导出一个函数和一个类
#pragma once#define _DLL_EXPORTS#ifdef _DLL_EXPORTS#define MYDLL_API __declspec(dllexport)#else#define MYDLL_API __declspec(dllimport)#endifMYDLL_API void MsgBox(const wchar_t*title, const wchar_t*content);class MYDLL_API testClass{public: void outputMessage(const wchar_t*msg);};
sourse.cpp
#include "stdafx.h"#include "head.h" void MsgBox(const wchar_t*title, const wchar_t*content){ MessageBox(NULL, title, content, MB_OK);} void testClass::outputMessage(const wchar_t*msg) { OutputDebugString(msg); }
测试代码:
#include "stdafx.h"#include "../../TestDll/TestDll/head.h"#pragma comment(lib,"../Debug/TestDll.lib")int main(){ MsgBox(_T("title"), _T("content")); testClass A; A.outputMessage(_T("aaaaaaaa")); return 0;}
代码链接:
http://download.csdn.net/detail/yangyang031213/9900474
阅读全文
0 0
- DLL导出
- DLL导出
- 导出DLL
- DLL导出
- DLL概念,DLL导出类
- 导出DLL的LIB
- dll导入和导出
- dll导入和导出
- 关于导出DLL问题
- DLL导出类问题
- DLL 导出类
- 导出和加载DLL
- vs2008 dll 导出函数
- 从dll导出lib
- 从dll导出lib
- 【zz】DLL 导出类
- dll导出函数
- DLL中导出对话框
- CSS选择器3
- 再聊tcp keepalive机制和与之相关的tcp RST
- 跨域请求XDM
- Linux下查看和添加PATH环境变量
- 理解Android Binder机制:驱动篇
- DLL导出
- Linux Signal handling(信号处理)Arm64
- ZOJ3958 Cooking Competition
- PAT1020~~~
- EXIT_SAPLL03A_012
- Selenium学习笔记(三)——访问连接和表格&鼠键事件
- 建造者模式
- MyBatis缓存
- Selenium学习笔记(四)——上传&下载文件