create.cpp
来自「COM技术内幕源码 ,随书原码」· C++ 代码 · 共 34 行
CPP
34 行
//
// Create.cpp
//
#include <iostream.h>
#include <unknwn.h> // 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() ;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?