Code: Select all
int CallMyDLL(void){
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\MyDLL.dll");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL), "MyFunc");
/* Define the Function in the DLL for reuse.
This is just prototyping the dll's function.
A mock of it. Use "stdcall" for maximum compatibility.
*/
typedef int (__stdcall * pICFUNC)(char *, int);
pICFUNC MyFunc;
MyFunc = pICFUNC(lpfnGetProcessID);
/* The actual call to the function contained in the dll */
int intMyReturnVal = MyFunc("hello", 5);
/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
/* The return val from the dll */
returnintMyReturnVal;
}