DLL初學者指南

2021-04-27 10:37:31 字數 950 閱讀 5054

這裡有兩個方法來載入乙個dll;乙個方法是捷徑另乙個則相比要複雜些。捷徑是只鏈結到你.lib 檔案並將.dll檔案置入你的新專案的路徑中去。因此,建立乙個新的空的win32控制台專案並新增乙個原始檔。將你做的dll放入你的新專案相同的目錄下。

#include

#include

_declspec(dllimport) void add();

//引入dll中的可匯出識別符號

int main()

你必需要鏈結到dlltutorial.lib檔案。我在專案屬性中設定了,但是你可能會用下面的語句代替:

#pragma comment(lib, "dlltutorial.lib")

請注意我讓編譯器來檢視我的dll資料夾已獲得.lib檔案同時讓它順便看下該目錄中的dll標頭檔案。如果你不想這麼做,你可以總是把他們放入你的新專案的目錄中並使用""(引號)而不是<>。這就是載入乙個dll的簡單方法。

顯示鏈結(動態鏈結)

there are three methods for exporting a definition, listed in recommended order of use:

the__declspec(dllexport)keyword in the source code

anexportsstatement in a .def file

an /export specification in a link command

all three methods can be used in the same program. when link builds a program that contains exports, it also creates an import library, unless an .exp file is used in the build.

DLL初學者指南

dll初學者指南 dll project的源 及測試專案 原文出處 codeguru 我正在學習dlls,談不上對其有什麼高屋建瓴的見解 本文只是 通過 編碼讓你看到並想知道 是如何執行的。在本文中,我假定你知道如何使用你的編譯器特性,比如設定目錄路徑等等。ifndef dll tutorial h...

DLL初學者指南

我正在學習dlls,談不上對其有什麼高屋建瓴的見解 本文只是 通過 編碼讓你看到並想知道 是如何執行的。在本文中,我假定你知道如何使用你的編譯器特性,比如設定目錄路徑等等。ifndef dll tutorial h define dll tutorial h include if defined d...

DLL初學者指南 非MFC

譯者 小刀人 dll project.rar dll project的源 及測試專案 原文出處 codeguru 我正在學習dlls,談不上對其有什麼高屋建瓴的見解 本文只是 通過 編碼讓你看到並想知道 是如何執行的。在本文中,我假定你知道如何使用你的編譯器特性,比如設定目錄路徑等等。ifndef ...