测试下dll的编写和调用
来源:互联网 发布:js中的大于等于 编辑:程序博客网 时间:2024/06/11 22:25
1、dll
#pragma once
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
__declspec(dllexport) int add(int a, int b);
#ifdef __cplusplus
}
#endif // __cplusplus
#include <iostream>
#include "DllTest.h"
int add(int a, int b)
{
return a + b;
}
2 、cpp 用dll 动态加载方法
#include<iostream>
#include <Windows.h>
#include "include\DllTest.h"
using namespace std;
typedef int(*ADDPROC)(int a, int b);
int main(int argc, char **argv)
{
HINSTANCE hInst = (HINSTANCE)LoadLibrary("ConsoleApplication1.dll");
if (hInst == NULL)
{
cout << "LoadLibrary error!" << endl;
return -1;
}
ADDPROC Add = (ADDPROC)GetProcAddress(hInst, "add");
if (NULL == Add)
{
cout << "GetProcAddress error!" << endl;
system("pause");
return -1;
}
cout << Add(20, 7) << endl;
FreeLibrary(hInst);
system("pause");
return 0;
}
///其他都不用设置,
- 测试下dll的编写和调用
- delphi编写与调用DLL(delphi7下测试通过)
- Delphi中高级DLL的编写和调用
- Delphi中高级DLL的编写和调用
- Delphi中高级DLL的编写和调用
- Delphi中高级DLL的编写和调用
- Delphi编写和调用DLL的重点
- Delphi中高级DLL的编写和调用
- Delphi中高级DLL的编写和调用
- VC下dll文件的编写和显式链接调用
- 编写和动态调用dll
- VC编写和调用dll
- DLL文件编写和调用
- MFC 下调用Qt编写的含界面的dll
- c#.net下成功调用c++编写的标准dll
- Windows下dll文件的编写与调用
- active 控件(ocx和dll)的编写和调用。
- DLL的编写与调用
- 实习总结系列3
- JSP页面跳转编码设置(Tomcat服务器)
- 图片轮播学习记录
- 【1602】关于1602仿真的问题合集
- Linux内核协议栈(附5) 协议栈中msghdr结构在2.6版本和4.0版本中的差异
- 测试下dll的编写和调用
- 栈的压入、弹出序列
- 栈溢出笔记1.2 覆盖EIP
- Android开发中对Bitmap的内存优化
- [LeetCode]1. Two Sum
- 进程调度原理
- Xcode常用的高效快捷键
- postgreSQL源码阅读计划
- View与ViewGroup--实现QQ左滑删除