|
// Create.cpp
#include "iostream.h"
#include "unknwn.h"
#include "Create.h"
typedef IUnknown* (*CREATEFUNCPTR)();
///////////////////////////////
void _TRACE(const char* msg)
{
cout << "Client :\t" <<msg<<endl;
}
/////////////////////////////////////////////
IUnknown* CallCreateInstance(char* dllname)
{
//-----------------------------------------------------------------------------------//
// Load dynamic link library into client's process.
//Loadlibrary maps a DLL module and return a handle that can be used in GetProcAddress
//to get the address of a DLL function
//----------------------------------------------------------------------------------//
_TRACE("Attempting to Load component's server...");
HMODULE hm = ::LoadLibrary(dllname) ;
if (hm == NULL)
{
_TRACE("CallCreateInstance:\tError: Cannot load the component's server.");
return NULL ;
}
// Getting the address of the CreateInstance function.
CREATEFUNCPTR Function= (CREATEFUNCPTR)::GetProcAddress(hm, "CreateInstance") ;
if (Function == NULL)
{
_TRACE("Function is not found!.");
return NULL ;
}
_TRACE("Component's server is loaded sucsussfully.");
return Function() ;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.