码迷,mamicode.com
首页 > 其他好文 > 详细

Dll

时间:2020-03-23 09:51:35      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:end   oid   无法   turn   lsp   nes   pre   nbsp   div   

// dll.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "iostream.h"
_declspec(dllexport) int add(int a,int b)
{
    return a+b;    
}

_declspec(dllexport) int sub(int a,int b)
{
    return a-b;    
}

_declspec(dllexport) int mul(int a,int b)
{
    return a*b;    
}

_declspec(dllexport) void print(int a,int b)
{
    cout<<"Fuck,XXXXX"<<endl;
}

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
                     )
{
    return TRUE;
}







// main.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream.h"
#pragma comment(lib,"dll.lib")

extern int add(int a,int b);
extern int sub(int a,int b);
extern int mul(int a,int b);
extern void print(int a,int b);
int main(int argc, char* argv[])
{
    cout<<add(1,2)<<endl;
    cout<<sub(1,2)<<endl;
    cout<<mul(1,2)<<endl;
    print(1,2);
    printf("Hello World!\n");
    return 0;
}




//在动态链接库编译执行完成以后,把生成的dll文件和lib文件拷贝到main函数的目录的Debug前一级目录中,否则会出现无法打开lib文件的情况

 

Dll

标签:end   oid   无法   turn   lsp   nes   pre   nbsp   div   

原文地址:https://www.cnblogs.com/butchert/p/12550024.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!