#include #include typedef void (WINAPI *BOOT)(void); void __declspec(dllimport) doIt( void ); int main( int argc, char **argv ) { char line[1024]; HMODULE ext; BOOT boot; doIt(); if( !( ext = LoadLibrary( argv[1] ) ) ) { printf( "Failed to load library %s: error: %d\n", argv[1], GetLastError() ); exit( -1 ); } if( !( boot = (BOOT)GetProcAddress( ext, "boot" ) ) ) { printf( "Failed to get proc address for boot; error: %d\n", GetLastError() ); exit( -2 ); } boot(); gets( line ); return 0; } #### #### #include int __declspec(dllimport) depFunc( int, double ); void __declspec(dllexport) doIt( void ) { printf( "MyDLL: depFunc return %d\n", depFunc( 42, 3.141592653 ) ); return; } #### #### #include int __declspec(dllexport) depFunc( int a, double b ) { printf( "depFunc: called with %d, %f\n", a, b ); return 1; } #### #### #include int __declspec(dllimport) depFunc( int, int ); void __declspec(dllexport) boot() { printf( "ExtDll: depFunc returned: %d\n ", depFunc( 12345, 98765 ) ); return; } #### #### #include int __declspec(dllexport) depFunc( int a, int b ) { printf( "depFunc: called with %d, %d\n", a, b ); return 1; } #### #### C:\test\myApp\Ext>cl /nologo /LD Dep.c Dep.c Creating library Dep.lib and object Dep.exp C:\test\myApp\Ext>mt /nologo -manifest Dep.dll.manifest -outputresource:Dep.dll;2 C:\test\myApp\Ext>cl /nologo /LD ExtDll.c Dep.lib ExtDll.c Creating library ExtDll.lib and object ExtDll.exp C:\test\myApp\Ext>mt /nologo -manifest ExtDll.dll.manifest -outputresource:ExtDll.dll;2 C:\test\myApp\Ext>cd .. C:\test\myApp>cl /nologo /LD Dep.c Dep.c Creating library Dep.lib and object Dep.exp C:\test\myApp>mt /nologo -manifest Dep.dll.manifest -outputresource:Dep.dll;2 C:\test\myApp>cl /nologo /LD myDll.c Dep.lib myDll.c Creating library myDll.lib and object myDll.exp C:\test\myApp>mt /nologo -manifest MyDll.dll.manifest -outputresource:MyDll.dll;2 C:\test\myApp>cl /nologo myApp.c MyDll.lib myApp.c C:\test\myApp>mt /nologo -manifest MyApp.exe.manifest -outputresource:MyApp.Exe;1 #### C:\test\myApp>MyApp.Exe Ext\ExtDll.dll depFunc: called with 42, 3.141593 MyDLL: depFunc return 1 depFunc: called with 12345, 98765 ExtDll: depFunc returned: 1