Sample - DDLs in C++: Implicit Linking Notes Code
Simple DLL that Prints a Text:
#include "iostream.h" //cout BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; } __declspec(dllexport) void WriteString() { cout << "This string printed from DLL ..." << endl; };
Calling DLL in Console Application:
#include <windows.h> //for HINSTANCE #include "iostream.h" /****************************************************************************** * Use of __declspec(dllimport) is optional, but it improves efficiency of the * * code. * *******************************************************************************/ /*__declspec(dllimport)*/ void WriteString(); void main() { WriteString(); }
Console Output:
This string printed from DLL ...
2002, Netston Consulting