How to use an external dll file in VisualStudio project

Date: Sep 19' 2012
by xyz

There are three approach to use the dll in our project, using '#pragma commen',
symbol '#import' or funciont 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.
posted @ 2012-09-19 15:52  qx.zhong  阅读(122)  评论(0编辑  收藏  举报