C++ exe调用dll文件
生成dll程序
extern "C"_declspec(dllexport) void maopao(int *p,int count);
void maopao(int *p,int count)
{
int temp=0;
for(int i=1;i<count;i++)
{
for(int j=count-1;j>=i;j--)
{
if(p[j]>p[j-1])
{
temp=p[j];
p[j]=p[j-1];
p[j-1]=temp;
}
}
}
}
调用dll文件(在调用dll时再)
#include<iostream>
#include<Windows.h>
#include<time.h>
typedef int(*Dllfun)(int *,int);
using namespace std;
int main()
{
Dllfun maopao1;
HINSTANCE hdll;
hdll=LoadLibrary("D:\\company\\soft\\C\\maopao_dll\\Debug\\maopao_dll.dll");
if(hdll==NULL)
{
FreeLibrary(hdll);
}
maopao1=(Dllfun)GetProcAddress(hdll,"maopao");
if(maopao1==NULL)
{
FreeLibrary(hdll);
}
int a[10];
srand(time(0));
for(int i=0;i<10;i++)
a[i]=rand()%50;
for(int i=0;i<10;i++)
cout<<a[i]<<' ';
cout<<endl;
maopao1(a,10);
for(int i=0;i<10;i++)
cout<<a[i]<<' ';
FreeLibrary(hdll);
}
把“unicode”改成支持多字符扩展
C++ exe调用dll文件的更多相关文章
- 有关windows系统的EXE和DLL文件说法错误
正确答案: B C 你的答案: C (错误) EXE和DLL文件都是PE文件 EXE不能有导出函数,DLL可以有导出函数 EXE有x86和x64之分,则DLL没有 EXE可以单独运行,DLL则不行 ...
- delphi 基础之三 编写和调用dll文件
delphi 编写和调用dll文件 Windows 的执行文件可以划分为两种形式程序和动态连接库 (DLLs).一般程序运行是用.EXE文件,但应用程序有时也可以调用存储在DLL的函数. 在如下几 ...
- PE头的应用---插入代码到EXE或DLL文件中
三.代码实现(DELPHI版本),采用第三种方式实现代码插入. 1. 定义两个类,一个用来实现在内存中建立输入表:一个用来实现对PE头的代码插入. DelphiCode: const MAX_SECT ...
- exe调用DLL的方式
假设被调用的DLL存在一个导出函数,原型如下: void printN(int); 三种方式从DLL导入导出函数 生成DLL时使用模块定义 (.def) 文件 在主应用程序的函数定义中使用关键字__d ...
- java中调用dll文件的两种方法
一中是用JNA方法,另外是用JNative方法,两种都是转载来的, JNA地址:http://blog.csdn.net/shendl/article/details/3589676 JNativ ...
- Java调用.dll文件
因为项目的需求,要在JAVA项目中调用Windows的Dll(动态链接库)文件,之前用Jni调用过C写的Dll文件,比较麻烦,这里不多说,网上也有很多这方面的文档.在网上找到一个开源的组件JNativ ...
- 使用ILmerge合并Exe、Dll文件的帮助类
原文:使用ILmerge合并Exe.Dll文件的帮助类 using System; using System.Collections.Generic; using System.Text; using ...
- LabVIEW如何方便地调用DLL文件
转自:http://bbs.elecfans.com/jishu_469502_1_1.html LabVIEW调用DLL文件 LabVIEW支持通过调用DLL文件的方式与其它编程语言混合使用.比 ...
- C#调用Dll文件中方法的简单应用
参考:http://www.cnblogs.com/Asuphy/p/4206623.html 直接看代码,最简单的引入,只需要3步: using System; using System.Colle ...
随机推荐
- PCA降纬一步一步
import numpy as np 第一步:原始值 X1 0.9 2.4 1.2 0.5 0.3 1.8 0.5 0.3 2.5 1.3 X2 1 2.6 1.7 0.7 0.7 1.4 0.6 0 ...
- FireDac 的RecordCount 相关测试 记录。
unit Unit4; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...
- Geometry关系高级操作
一些高级的操作 几何形状Geometry缓冲(buffer) 线段的融合(linemerge)是将Geometry A中相互连接的线段进行连接 多边形化操作(polygonize)对Geometry ...
- 无向图的DFS遍历(方法之一)
如果看不懂辅助解释在后面第点 1.录入方式: 输入 u - v 表示一边的2个端点 2.存储结构 struct edge { int from; int to; int next; } e[MAXN ...
- Asp.Net 4.0 FormAuthentication 原理
建立一个使用Asp.Net Membership管理登陆登出信息的网站 1. 创建一个Asp.Net Mvc 3 示例网站. 2. 创建自定义的MemberShipProvider,并在Web.CON ...
- C# 采用事务批量插入数据
首先要构建一个实体类,注意实体类的属性和数据的列要一一对应,否则会报错. public class Animal { public string Name { get; set; } public i ...
- vc++ 程序开机自启动和取消启动
//开机启动 int CMainWnd::CreateRun() { //添加以下代码 HKEY hKey; }; //得到程序自身的全路径 DWORD dwRet = GetModuleFileNa ...
- Python+Google Geocoding
本文主要介绍使用Python调用Google Geocoding API进行地址到地理坐标的转换. Google Geocoding参考https://developers.google.com/ma ...
- Python执行系统命令的方法 os.system(),os.popen(),commands
os.popen():用python执行shell的命令,并且返回了结果,括号中是写shell命令 Python执行系统命令的方法: https://my.oschina.net/renwofei42 ...
- ARM开发板上iconv调用失败的解决方法
当前流行的字符编码格式有:US-ASCII.ISO-8859-1.UTF-8.UTF-16BE.UTF-16LE.UTF-16.GBK.GB2312等,其中GBK.GB2312是专门处理中文编码的.而 ...