MiniM Knowledge Base | Jul 29, 2011
How to Dynamically Load minimsc.dll
MiniM Server Connect have examples with static linking. This way requires getting special lib file. In any case this library may be loaded dynamically without static linking.
To load MiniM Server Connect dynamic link library dynamically it is need to prepare some standard steps:
All this steps are standard for windows developers. To make this steps properly programmer requires call conventions and naming conventions. They are:
This article contains an example ho to do this and sources are compiled by Microsoft Visual Studio. The same actions may be done by all another C or C++ compilers (Intel, Watcom etc) for Windows and this way does not requires to make static link library file.
Function prototypes are declared in source file minimsc.h. So, to load functions dynamically developer must have declarations of pointers to functions properly: if we have
HMNMConnect MNMSCPROC MNMCreateConnect( char* server, int port, char* database);
then we must declare type of pointer to function:
typedef HMNMConnect (__stdcall * mnmcreateconnect_t)( char* server, int port, char* database);
Example contains types declarations for minimsc.dll exported functions, pointers declarations and code to load dll and execute the same first two examples which are installed with MiniM Server Connect.
Header file minimscdyn.h contains type declarations.
Source file dyncppexam1.cpp contains pointers to functions and code to execute.
Function LoadMNMSC() in this example prepares dynamic library loading and initialises pointers to functions. After this function executes correctly, all function pointers may be used as an ordinal functions, linker already know what addresses must be called.
Functions DoExample1() and DoExample2() are copies of first two standard MiniM Server Connect examples.
Function FreeMNMSC() unloads library and clears pointers to functions to prevent calls to unexistent code.
Before run this example developer must change value of the libfilename variable to file name of minimsc.dll or to full file name (in depending where this file was installed).