小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

VS2010中創(chuàng)建DLL圖解

 @IT小小鳥(niǎo)@ 2012-02-15
VS2010中 C++創(chuàng)建DLL圖解

一、DLL的創(chuàng)建 
創(chuàng)建項(xiàng)目: Win32->Win32項(xiàng)目,名稱:MyDLL


選擇DLL (D) ->完成.

1、新建頭文件testdll.h
testdll.h代碼如下:
#ifndef TestDll_H_
#define TestDll_H_
#ifdef MYLIBDLL
#define MYLIBDLL extern "C" _declspec(dllimport) 
#else
#define MYLIBDLL extern "C" _declspec(dllexport) 
#endif
MYLIBDLL int Add(int plus1, int plus2);
//You can also write like this:
//extern "C" {
//_declspec(dllexport) int Add(int plus1, int plus2);
//};
#endif



2、新建源文件testdll.cpp
testdll.cpp代碼如下:
#include "stdafx.h"
#include "testdll.h"
#include <iostream>
using namespace std;
int Add(int plus1, int plus2)
{
int add_result = plus1 + plus2;
return add_result;
}




3、新建模塊定義文件mydll.def
mydll.def代碼如下:
LIBRARY "MyDLL"
EXPORTS
Add @1


4、vs2010自動(dòng)創(chuàng)建dllmain.cpp文件,它定義了DLL 應(yīng)用程序的入口點(diǎn)。

dllmain.cpp代碼如下:
// dllmain.cpp : 定義 DLL 應(yīng)用程序的入口點(diǎn)。
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
      )
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
  break;
}
return TRUE;
}

最后,編譯生成MyDLL.dll文件和MyDLL.lib文件。

1>------ 已啟動(dòng)生成: 項(xiàng)目: MyDLL, 配置: Debug Win32 ------

1>  dllmain.cpp

========== 生成: 成功 1 個(gè),失敗 0 個(gè),最新 0 個(gè),跳過(guò) 0 個(gè) ==========

 

1>------ 已啟動(dòng)生成: 項(xiàng)目: MyDLL, 配置: Debug Win32 ------

1>  stdafx.cpp

1>  testdll.cpp

1>  MyDLL.cpp

1>  正在生成代碼...

1>     正在創(chuàng)建庫(kù) D:\Visual C++\工程\Libaray\MyDLL\Debug\MyDLL.lib 和對(duì)象 D:\Visual C++\工程\Libaray\MyDLL\Debug


    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多