Notes:
| click | file->new->projects->"Win32 Dynamic-Link Library" |
| enter | "DllDemoEmpty1" in the project name text box |
| click | ok |
| select | an empty DLL project |
| click | finish |
| click | file->new->files->"c++ source file" |
| enter | "DllDemoEmpty1.cpp" in the file name text box |
| click | ok |
| paste | the contents of DllDemoEmpty1.h (below) into this window |
| click | file->new->files->"c/c++ header file" |
| enter | "DllDemoEmpty1.h" in the file name text box |
| click | ok |
| paste | the contents of DllDemoEmpty1.cpp (below) into this window |
| press | key "F7" to build |
| click | file menu->new->project |
| click | Visual C++ Projects (in left hand pane) |
| click | Empty Project .net (in right hand pane) |
| enter | "DllDemoEmpty1" in the project name text box |
| click | ok |
| click | view menu->solution explorer (only if solution explorer is not visible in the left hand pane) |
| right click | on "DllDemoEmpty1" then click on "properties" |
| double click | on configuration properties |
| click | on general |
| click | on configuration type |
| select | "Dynamic Library (.dll)" from the drop down menu |
| click | on "Use Managed Extensions" |
| select | "No" from the drop down menu (we do not want to invoke the common language runtime) |
| click | "use of MFC" |
| select | "use standard Windows Libraries" from the drop down menu |
| click | "use of ATL" |
| select | "not using ATL" from the drop down menu |
| click | ok |
| right click | on the "header files" folder |
| click | "add->add new item" or "add->add existing item" to add file "DllDemoEmpty1.h" |
| right click | on the "source files" folder |
| click | "add-add new item" or "add->add existing item" to add file "DllDemoEmpty1.cpp" |
| right click | on the "DllDemoEmpty" project folder |
| click | on "rebuild" |
//============================================================ // title : DllDemoEmpty1.h // purpose: required for DllDemoEmpty1.DLL // author : Neil Rieck // notes : http://www3.sympatico.ca/n.rieck //============================================================ #ifndef __DllDemoEmpty1_H // #define __DllDemoEmpty1_H // #ifndef __DllDemoEmpty1__ // define when calling from DLL #define __DllDemoEmpty1LIB__ __declspec(dllimport) // used when called from app #else // #define __DllDemoEmpty1LIB__ __declspec(dllexport) // used when called from demo #endif // ifndef else __DllDemoEmpty1__ // // <<< prototype(s) // // these functions will be tagged for either import or export // __DllDemoEmpty1LIB__ unsigned long SimpleDouble( unsigned long whatever); __DllDemoEmpty1LIB__ unsigned long SimpleTriple( unsigned long whatever); #endif // ifndef __DllDemoEmpty1_H
//============================================================ // title : DllDemoEmpty1.cpp // purpose: this program builds into DllDemoEmpty1.DLL // author : Neil Rieck // notes : http://www3.sympatico.ca/n.rieck //============================================================ #define __DllDemoEmpty1__ // force export mode #include "DllDemoEmpty1.h" // get exported prototypes // // note: this program doesn't have a function called DllMain() // //------------------------------------------------------------ // this function doubles whatever it receives // (it has been marked for export in "DllDemoEmpty1.h") //------------------------------------------------------------ unsigned long SimpleDouble( unsigned long whatever) { return (2 * whatever); } //------------------------------------------------------------ // this function triples whatever it receives // (it has been marked for export in "DllDemoEmpty1.h") //------------------------------------------------------------ unsigned long SimpleTriple( unsigned long whatever) { return (3 * whatever); }
| click | file->new->projects->"Console Application" |
| enter | "DllDemoEmpty1Test" in the project name text box |
| click | ok |
| select | a "Hello World" project |
| click | finish |
| edit | "DllDemoEmpty1Test.cpp" replace that code with the code below |
| copy | files "DllDemoEmpty1.h", "DllDemoEmpty1.lib", "DllDemoEmpty1.dll" to this directory |
| click | project->settings->link then add DllDemoEmpty1.lib to the end of the
"Object/Library Modules" text box (just click inside the box then press the "end" key) |
| press | key "F7" to build |
//============================================================
// title : DllDemoEmpty1Test.cpp
// purpose: tests DllDemoEmpty1.DLL
// author : Neil Rieck
// notes : http://www3.sympatico.ca/n.rieck
//============================================================
#include <iostream>
#include "DllDemoEmpty1.h" // get our function definitions
using std::cout;
using std::endl;
void main()
{ cout << "DllDemoEmpty1Test" << endl;
cout << "=================" << endl;
cout << "2*20=" << SimpleDouble(20) << endl;
cout << "3*30=" << SimpleTriple(30) << endl;
}

Back
to Home