2025-04-27 07:49:33 -04:00

46 lines
1.2 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// %%Includes: ---------------------------------------------------------------
#define INC_OLE2
#define STRICT
#include <mdcommon.hxx>
DWORD g_dwRegister;
// ---------------------------------------------------------------------------
// %%Function: main
// ---------------------------------------------------------------------------
BOOL
InitComMetadata(BOOL bRunAsExe)
{
HRESULT hr;
BOOL bReturn = TRUE;
// initialize COM for free-threading
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hr)) {
bReturn = FALSE;
}
CMDCOMSrvFactory *pMDClassFactory = new CMDCOMSrvFactory;
// register the class-object with OLE
hr = CoRegisterClassObject(GETMDCLSID(!bRunAsExe), pMDClassFactory,
CLSCTX_SERVER, REGCLS_MULTIPLEUSE, &g_dwRegister);
if (FAILED(hr)) {
bReturn = FALSE;
}
return bReturn;
} // main
BOOL
TerminateComMetadata()
{
if( FAILED( CoRevokeClassObject(g_dwRegister) ) )
{
return FALSE;
}
CoUninitialize();
return TRUE;
}
// EOF =======================================================================