您的位置:首页 > 其它

How to use an external dll file in VisualStudio project

2012-09-19 15:52 701 查看
Date: Sep 19' 2012

by xyz

There are three approach to use the dll in our project, using '#pragma commen',

symbol '#import' or function LoadLibrary decleared by file <Windows.h>. But now,

we discuss the first way, and it ask we to prepare three parts of the dll: headfile,

.lib and the .dll file also. Assume we have three parts of an exsited project.

File list:

a. MyHeadFile.h

b. MyLib.lib

c.  MyLib.dll

Now please open your vs solution and complete the follow steps:

-----------------------------------------------------------

 a. open project's [properties]

b. select [Configuration Properites] -> [VC+ Directores], in the right Greneral page,

fill the full path of file MyHeadFile.h into [Include Directories], and fill the

[LibraryDirectories] with File MyLib.lib path.

 c. go back to left bar, find [Linker] and select [Input] in the layer list.

 d. fill file MyLib.dll' name in table [Additional Dependencies].

 e. select OK to save your change and quit.

How to use the exports class or functions in the dll file?

-------------------------------------------------------------

Open your main file in the current solution, and include the head file you need,

in this sample , it would be #include "MyHeadFile.h", and don't forget to using macro

#pragma comment(lib,"MyLib.lib") in your main source file. After finished the whole

steps above, you can use the classes or functions that decleared and implemented in

the .dll file your just import.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息