当前位置: 首页>>代码示例>>C++>>正文


C++ CComObject::CreateInstance方法代码示例

本文整理汇总了C++中CComObject::CreateInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ CComObject::CreateInstance方法的具体用法?C++ CComObject::CreateInstance怎么用?C++ CComObject::CreateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CComObject的用法示例。


在下文中一共展示了CComObject::CreateInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FinalConstruct

HRESULT CPigShip::FinalConstruct()
{
    // Create a dummy event so that AutoAction always returns an object
    CComObject<CPigShipDummyEvent>* pDummyEvent = NULL;
    RETURN_FAILED(pDummyEvent->CreateInstance(&pDummyEvent));
    m_spDummyEvent = pDummyEvent;
    assert(NULL != m_spDummyEvent);

    // Indicate success
    return S_OK;
}
开发者ID:BackTrak,项目名称:Allegiance-R4-Engine,代码行数:11,代码来源:PigShip.cpp

示例2: AddScriptFile

void CPigEngine::AddScriptFile(const WIN32_FIND_DATA* pffd,
  tstring strFileName)
{
  // Create a new CPigBehaviorScriptType object
  CComObject<CPigBehaviorScriptType>* pScript = NULL;
  HRESULT hr = pScript->CreateInstance(&pScript);
  ZSucceeded(hr);
  if (SUCCEEDED(hr))
  {
    // AddRef the new object
    pScript->AddRef();

    // Initialize the new object
    LoadScriptFile(pScript, pffd, strFileName);

    // Add the new object to the map of scripts
    XLock lock(this);
    m_mapScripts.insert(std::make_pair(strFileName, pScript));
  }
}
开发者ID:borgified,项目名称:Allegiance,代码行数:20,代码来源:PigEngine.cpp

示例3: GetDispatch

// GetDispatch --------------------------------------------------------------
LPDISPATCH CCodeListCtrl::GetDispatch()
{
#ifdef _ACTIVEX

   if( NULL == m_lpDispatch )
   {
      CComObject<CICodeList>* pNew = NULL;
      HRESULT hR = pNew->CreateInstance( &pNew );

      if( SUCCEEDED( hR ) )
      {
         pNew->AddRef();
         pNew->SetControl( this );
         m_lpDispatch = pNew;
      }
   }

#endif//#ifdef _ACTIVEX

   return m_lpDispatch;
}
开发者ID:DeegC,项目名称:ZeidonTools,代码行数:22,代码来源:codelistctrl.cpp

示例4: FinalConstruct

HRESULT CAdminSession::FinalConstruct()
{
	// #define CAdminSession_TRACE_CONSTRUCTION
#ifdef CAdminSession_TRACE_CONSTRUCTION
	_TRACE_BEGIN
		DWORD id = GetCurrentThreadId();
	_TRACE_PART2("CAdminSession::FinalConstruct(): ThreadId = %d (0x%X)\n", id, id);
	_TRACE_PART1("\tRaw pointer = 0x%08X\n", this);
	_TRACE_END
#endif // CAdminSession_TRACE_CONSTRUCTION

		// Create the event sink object
		CComObject<CAdminSessionEventSink>* pEventSink = NULL;
	RETURN_FAILED(pEventSink->CreateInstance(&pEventSink));
	pEventSink->AddRef();
	pEventSink->Init(this);
	m_pEventSink = pEventSink;

	// Indicate success
	return S_OK;
}
开发者ID:AllegianceZone,项目名称:Allegiance,代码行数:21,代码来源:AdminSession.cpp

示例5: assert

/////////////////////////////////////////////////////////////////////
// I4CLOpen
/////////////////////////////////////////////////////////////////////
STDMETHODIMP C4CLAccessLib::Open(
    /*[in]*/         BOOL          bWrite,
    /*[in, string]*/ BSTR          sFileName,
    /*[out,string]*/ BSTR*         psErrorDescr,
    /*[out]*/        I4CLAccess**  ppIAcc
)
{
    USES_CONVERSION;
    HRESULT                 hr;
    CComObject<CLibObject>* pLib;

    *psErrorDescr = NULL;
    *ppIAcc       = NULL;


    // create instance of library-accessor COM-object and open the archive:
    hr = pLib->CreateInstance(&pLib);
    pLib->AddRef();

    if(SUCCEEDED(hr))
    {
        hr = pLib->openAr(OLE2T(sFileName), bWrite?true:false, psErrorDescr);
        if(hr == S_OK)
            *ppIAcc = pLib;
        else
            pLib->Release();
    }
    else
    {
        FC_CString jot;

        assert(!"CreateInstance for I4CLAccess failed");
        jot.fmtSysErr(hr);
        *psErrorDescr = jot.toBSTR();
    }
    return hr;
}
开发者ID:LM25TTD,项目名称:ATCMcontrol_Engineering,代码行数:40,代码来源:LowLevelLib.cpp

示例6: Construct

HRESULT CPigEngine::Construct()
{
  // Get the path name of the module
  TCHAR szModule[_MAX_PATH];
  _VERIFYE(GetModuleFileName(_Module.GetModuleInstance(), szModule,
    sizeofArray(szModule)));

  // Break the path name of the module into pieces
  TCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szName[_MAX_FNAME];
  _tsplitpath(szModule, szDrive, szDir, szName, NULL);

  // Open the registry key of the AppID
  CRegKey key;
  RETURN_FAILED(_Module.OpenAppIDRegKey(key, KEY_READ));

  // Create the event logger object
  RETURN_FAILED(m_spEventLogger.CreateInstance("AGC.EventLogger"));

  // Initialize the event logger object
  CComBSTR bstrEventSource(L"PigSrv");
  CComBSTR bstrRegKey(L"HKCR\\AppID\\{F132B4E3-C6EF-11D2-85C9-00C04F68DEB0}");
  IAGCEventLoggerPrivatePtr spPrivate(m_spEventLogger);
  RETURN_FAILED(spPrivate->Initialize(bstrEventSource, bstrRegKey));

  // Load the MissionServer registry value
  LoadRegString(key, TEXT("MissionServer"), m_bstrMissionServer);

  // Load the AccountServer registry value
  LoadRegString(key, TEXT("AccountServer"), m_bstrAccountServer);

  // Load the ZoneAuthServer registry value
  LoadRegString(key, TEXT("ZoneAuthServer"), m_bstrZoneAuthServer);

  // Load the ZoneAuthTimeout registry value
  DWORD dwZoneAuthTimeout;
  if (ERROR_SUCCESS == key.QueryValue(dwZoneAuthTimeout, TEXT("ZoneAuthTimeout")))
    m_nZoneAuthTimeout = static_cast<long>(dwZoneAuthTimeout);

  // Load the LobbyMode registry value
  DWORD dwLobbyMode;
  if (ERROR_SUCCESS == key.QueryValue(dwLobbyMode, TEXT("LobbyMode")))
    m_eLobbyMode =
      (PigLobbyMode_Club <= dwLobbyMode && dwLobbyMode <= PigLobbyMode_Free) ?
        static_cast<PigLobbyMode>(dwLobbyMode) : PigLobbyMode_Club;

  // Attempt to read the ScriptDir value from the registry
  ZString strScriptDir;
  LoadRegString(key, TEXT("ScriptDir"), strScriptDir);

  // Create a directory name from the root directory, by default
  if (strScriptDir.IsEmpty())
  {
    TCHAR szScriptDir[_MAX_PATH + 1];
    _tmakepath(szScriptDir, szDrive, szDir, TEXT("Scripts"), NULL);
    strScriptDir = szScriptDir;
  }

  // Ensure that m_bstrScriptDir ends with a whack
  int nLastChar = strScriptDir.GetLength() - 1;
  if (TEXT('\\') != strScriptDir[nLastChar])
    strScriptDir += ZString("\\");

  // Save the directory name
  m_bstrScriptDir = strScriptDir;

  // Create the pigs collection object with a ref count
  assert(!m_pPigs);
  CComObject<CPigs>* pPigs = NULL;
  RETURN_FAILED(pPigs->CreateInstance(&pPigs));
  (m_pPigs = pPigs)->AddRef();

  // Indicate success
  return S_OK;
}
开发者ID:borgified,项目名称:Allegiance,代码行数:74,代码来源:PigEngine.cpp


注:本文中的CComObject::CreateInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。