COM Utility
COM 工具類,誰用誰知道!
#ifndef COMUtility_H
#define COMUtility_H
//////////////////////////////////////////////////////////////////////////
#include <Windows.h>
//////////////////////////////////////////////////////////////////////////
// define the prototype of the class factory entry point in a COM dll
typedef HRESULT (STDAPICALLTYPE *DllGetClassObjectT)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
//////////////////////////////////////////////////////////////////////////
template <DWORD dwUnique>
class COMUtilityT
{
public:
static HRESULT CreateObjectFromPath(REFCLSID clsid, IUnknown **ppUnk, LPCSTR lpszPath)
{
// load the target DLL directly
HMODULE hModule = LoadLibraryA(lpszPath);
if (hModule == NULL) {
return HRESULT_FROM_WIN32(GetLastError());
}
return CreateObjectFromPath(hModule, clsid, ppUnk);
}
static HRESULT CreateObjectFromPath(REFCLSID clsid, IUnknown **ppUnk, LPCWSTR lpszPath)
{
// load the target DLL directly
HMODULE hModule = LoadLibraryW(lpszPath);
if (hModule == NULL) {
return HRESULT_FROM_WIN32(GetLastError());
}
return CreateObjectFromPath(hModule, clsid, ppUnk);
}
private:
static HRESULT CreateObjectFromPath(HMODULE hModule, REFCLSID clsid, IUnknown **ppUnk)
{
if (hModule == NULL) {
return HRESULT_FROM_WIN32(GetLastError());
}
// the entry point is an exported function
DllGetClassObjectT fn = (DllGetClassObjectT) GetProcAddress(hModule, "DllGetClassObject");
if (fn == NULL) {
return HRESULT_FROM_WIN32(GetLastError());
}
// create a class factory
CComPtr<IUnknown> pUnknown;
HRESULT hr = fn(clsid, IID_IUnknown, (LPVOID *) &pUnknown);
if (SUCCEEDED(hr)) {
CComQIPtr<IClassFactory> pClassFactory(pUnknown);
if (pClassFactory == NULL) {
hr = E_NOINTERFACE;
}
else {
// ask the class factory to create the object
hr = pClassFactory->CreateInstance(NULL, IID_IUnknown, (LPVOID *) ppUnk);
}
}
return hr;
}
};
//////////////////////////////////////////////////////////////////////////
typedef COMUtilityT<0> COMUtility;
//////////////////////////////////////////////////////////////////////////
#endif
相關文章
- File Compare Utility 3.0.002
- DBMS_UTILITY.COMPILE_SCHEMACompile
- ASMCMD - ASM command line utility .ASM
- Run Repository Creation Utility (RCU) for Oracle Identity Management componentsOracleIDE
- dbverify Utility
- DirectShow Utility
- Utility FilterFilter
- PG: Utility queries
- dbms_utility
- DBNEWID Utility
- OCP(11g)------> ASM Command-Line Utility (ASMCMD)和 使用 ASMCMDASM
- DBVERIFY utility的使用
- A Facial Recognition utility in a dozen of LOC
- ASM Metadata Dump UtilityASM
- DBMS_Utility學習
- DBMS_UTILITY.ANALYZE_SCHEMA
- dbms_utility.get_time
- Partition|Disk Utility 如何分割磁碟
- SMART Utility for mac (硬碟檢測)Mac硬碟
- enable run glance utility in windows CMDWindows
- 硬碟檢測工具:SMART Utility for mac硬碟Mac
- SMART Utility for Mac:硬碟健康的守護者Mac硬碟
- Tracing the LSNRCTL Control Utility
- macOS Developer Beta Access Utility(蘋果開發者工具)MacDeveloper蘋果
- Oracle AMDU- ASM Metadata Dump UtilityOracleASM
- DBMS_UTILITY.FORMAT_ERROR_BACKTRACE FunctionORMErrorFunction
- dbms_utility的兩個有用方法
- underscore 系列之防衝突與 Utility FunctionsFunction
- [Upgrade] Oracle 10.2.0.5 opatch utility upgradeOracle
- HP Array Configuration Utility CLI命令
- Oracle Streams STRMMON Monitoring Utility [ID 290605.1]Oracle
- 討論:關於The REBIND utility and the FLUSH PACKAGE CACHEPackage
- Dynamics CRM Xrm.Utility.openEntityForm passing lookup parametersORM
- SMART Utility for mac (硬碟檢測) 3.2.7啟用版Mac硬碟
- SMART Utility:您的Mac硬碟健康守護神Mac硬碟
- GoldenGate replication using a data definition file and DEFGEN utilityGo
- 由Rdba發現 block地址(使用dbms_utility)BloC
- LUT Utility for FCPX(Luts調色檔案載入工具)