www.pudn.com > COM技术内幕配书源码.rar > CREATE.CPP
// // Create.cpp // #include#include // Declare IUnknown. #include "Create.h" typedef IUnknown* (*CREATEFUNCPTR)() ; IUnknown* CallCreateInstance(char* name) { // Load dynamic link library into process. HINSTANCE hComponent = ::LoadLibrary(name) ; if (hComponent == NULL) { cout << "CallCreateInstance:\tError: Cannot load component." << endl ; return NULL ; } // Get address for CreateInstance function. CREATEFUNCPTR CreateInstance = (CREATEFUNCPTR)::GetProcAddress(hComponent, "CreateInstance") ; if (CreateInstance == NULL) { cout << "CallCreateInstance:\tError: " << "Cannot find CreateInstance function." << endl ; return NULL ; } return CreateInstance() ; }