Back

// PSLCores.cpp : Implementation of CPSLCores

#include "stdafx.h"
#include "PSLCore.h"
#include "PSLCores.h"

CPSLCores::CPSLCores()
{
}

HRESULT CPSLCores::OnIndexOutOfRange()
{
   return MakeException(EX_INDEXOUTOFRANGE);
}

HRESULT CPSLCores::FinalConstruct()
{
   PSL_BEGIN

   InternalUpdate();

   PSL_END
}

void CPSLCores::FinalRelease()
{
}

void CPSLCores::InternalUpdate()
{
   CCritSecLock cs(m_csCollection);
   m_coll.clear();
   HKEY hkResult = 0;
   int CPUIndex = 0;
   TCHAR buffer[64];
   while(1)
   {
      ::swprintf_s(buffer, 64, _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d"), CPUIndex);
      if(::RegOpenKeyEx(HKEY_LOCAL_MACHINE, buffer, 0, KEY_READ, &hkResult) != ERROR_SUCCESS)
         break;
      ::RegCloseKey(hkResult);
      CPUIndex ++;
      CComObject<CPSLCore> * pCore = NULL;
      if(CComObject<CPSLCore>::CreateInstance(&pCore) == S_OK)
      {
         pCore->Initialize(buffer);
         m_coll.push_back(CComPtr<IPSLCore>(pCore));
      }
   }
}

////////////////////////////////////////////////////////////////////////
// Interface Implementation;
////////////////////////////////////////////////////////////////////////

Top