extern unsigned _func_name( version_dll ) ( /*****************************************/ void ) { HANDLE lib; FARPROC ver_dll_num; unsigned ver; strupr( VersionDllProc ); lib = LoadLibrary( _xstr( DLL_FILE_NAME ) ); if( lib < (HANDLE)32 ) { /* couldn't load the dll so the version is 0 */ ver = 0; } else { ver_dll_num = GetProcAddress( lib, VersionDllProc ); if( ver_dll_num == NULL ) { ver = 0; } else { ver = ((unsigned(*)(void))(*ver_dll_num)) (); } FreeLibrary( lib ); } return( ver ); }
into the dll and must NOT be put in the import library (although references to its exported functions are ok). */ #include <windows.h> #include "version.h" #define WINIEXP __export far PASCAL // use with in-obj export rtns #define _glue( a, b ) a ## b #define _xglue( a, b ) _glue( a, b ) #define _str(a) # a #define _xstr(a) _str(a) #define _func_name( func ) _xglue( DLL_PREFIX, func ) #pragma off (unreferenced); static char VersionStr[] = "Version Verification: " _xstr( DLL_FILE_NAME ) " actual version " _xstr( DLL_VERSION ); unsigned WINIEXP _func_name( version_dll_num ) ( /**********************************************/ void ) { return( DLL_VERSION ); }
*/ #include <windows.h> #include <string.h> #include "version.h" #define _glue( a, b ) a ## b #define _xglue( a, b ) _glue( a, b ) #define _str(a) # a #define _xstr(a) _str(a) #define _func_name( func ) _xglue( DLL_PREFIX, func ) #pragma off (unreferenced); static char VersionDllProc[] = _xstr( _func_name( version_dll_num ) ); static char VersionStr[] = "Version Verification: " _xstr( DLL_FILE_NAME ) " expected version " _xstr( DLL_VERSION ); extern unsigned _func_name( version_import ) ( /********************************************/ void ) { return( DLL_VERSION ); } extern unsigned _func_name( version_dll ) ( /*****************************************/ void