C + + Write DLL, in C + + call is actually a relatively simple thing, call DLL function method In fact there are many, say one of the most common method:
1. Create a new solution, file--New project->visual C++->WIN32 Console application->next->dll-> complete.
2. Static (. lib), configuration type, project properties.
3. lib2.h File:
Class Lib2 {public: Lib2 (); ~lib2 (); int calc (int val2);};
4. lib3.cpp File:
"stdafx.h""lib2.h"lib2::lib2 () {}lib2::~lib2 () {}int lib2::calc (int val2 ) {return val1 + val2;}
5. Build the solution
6. Create a new Visual Studio, create a new->visual C++>WIN32 console Application->next-> console application->next->finshe.
7, the->c++ directory in the project properties, including the directory where the directory is added lib2.h. Library directory Select the directory of DLLs and LIB, typically the debug directory under LIB2 solution.
8, additional dependencies, input, linker, item properties, and so on, add to Lib2.lib
9,
"stdafx.h"#include <iostream>#include <lib2.h>int main () {lib2* lib=new LIB2; int result = Lib->calc (6"Result:" << result << Std::endl; 0;}
10, F5 operation can be.
Rookie Advanced: VC + + in Visual Studio DLL call implementation [static embedding]