Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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));
  }
}
Exemplo n.º 3
0
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;
}
/////////////////////////////////////////////////////////////////////
// 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;
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
-2
// 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;
}