一:创建C++ DLL类库,名称:Dll1

1.Dll1.h

/*#ifndef Dll_API
#else
#define Dll_API _declspec(dllimport)
#endif */
#include "stdafx.h" class _declspec(dllexport) Point
{
public:
int output(int x,int y); };

  2.Dll1.cpp

// Dll1.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include"Dll1.h"
#include "iostream"
using namespace std; int Point::output(int x,int y)
{
return (x+y); };

  二:C++启动项目win32项目,名称:CeshiDllClass

1.CeshiDllClass.h

#include "stdafx.h"
class _declspec(dllimport) Point
{
public:
int output(int x,int y); };

2.CeshiDllClass.cpp

// CeshiDllClass.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include "CeshiDllClass.h"
//#include "E:\visual studio 2008\project\CeshiDllClass\Dll1\Dll1.h"
#include<iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[])
{
Point a; cout<<a.output(1,2)<<endl;
return 0;
}

三:配置

1.想将dll文件copy到启动项目的debug中去。

2。按照下图中的红框来设置。我不明白我的为什么要在这里加引用,如果不加,它就会报错,解析不了,网上的都没有加,所以在这里碰到了很多的挫折。

3. 结果

在dos命令窗口出现1+2的结果 3

这都是测试用的数据,所以就简单的用了下加法运算。如有疑问请给我联系。

最新文章

  1. Linux虚拟机安装(CentOS 6.5,图文详解,需要自查)
  2. Google Chrome can not be run as root
  3. 如何安装altium designer 10
  4. Fine Uploader文件上传组件
  5. docker制作node程序镜像:
  6. 获取一个Jpanel的父容器有多难
  7. js 如何动态添加数组_百度知道
  8. Winform退出运行后,删除运行目录(批处理方法)
  9. echo 输入背景和字体常用方法
  10. 【原】Java学习笔记007 - 流程控制
  11. python之用unittest实现接口参数化示例
  12. 【kindle笔记】之 《活着》-2018-2-5
  13. qrcode.js 动态生成二维码
  14. 【问题解决:信息提示】SpringBoot启动时提示The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
  15. postgresql-删除重复数据
  16. 绘图QPainter-字体
  17. eclipse安装主题插件(Color Theme)
  18. Visual Studio 2015+InstallShield 2015
  19. 多进程共享数据,真正的通信Manager
  20. 轻型DNS服务器dnsmasq

热门文章

  1. git之项目上传
  2. delphi三层架构
  3. IE WebDeveloper--IE浏览器web调试工具
  4. vs code 配置spring boot开发环境
  5. 【POJ1509】Glass Beads 【后缀自动机】
  6. 【hdu4135】【hdu2841】【hdu1695】一类通过容斥定理求区间互质的方法
  7. 346. Moving Average from Data Stream数据窗口流中位数的数据结构设计
  8. mysql5.6新建的user为啥会看到没有授权过的db?
  9. RTX二次开发::检索 COM 类工厂中 CLSID 为 {79210E58-99EB-45D0-8890-763EFEAA143F} 的组件失败,
  10. Cisco VPP启动流程