Click here to Skip to main content
15,894,460 members
Articles / Programming Languages / VBScript

ProSysLib: Dissecting the Process

Rate me:
Please Sign up or sign in to vote.
4.84/5 (69 votes)
22 Nov 2010CPOL12 min read 129.1K   2.6K   174  
Access detailed information about the current process the easiest way.
// PSLMonitors.cpp : Implementation of CPSLMonitors

#include "stdafx.h"
#include "PSLMonitor.h"
#include "PSLMonitors.h"


CPSLMonitors::CPSLMonitors()
{
}

HRESULT CPSLMonitors::OnIndexOutOfRange()
{
	return MakeException(exIndexOutOfRange);
}

HRESULT CPSLMonitors::FinalConstruct()
{
	PSL_BEGIN

	InternalUpdate();
	
	PSL_END
}

void CPSLMonitors::FinalRelease()
{
}

BOOL CALLBACK CPSLMonitors::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
	vector<HMONITOR> * pMonitors = (vector<HMONITOR>*)dwData;
	pMonitors->push_back(hMonitor);
	return TRUE;
}

void CPSLMonitors::InternalUpdate()
{
	CCritSecLock cs(m_csCollection);
	m_coll.clear();

	vector<HMONITOR> monitors;
	::EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&monitors);

	CComObject<CPSLMonitor> * pMonitor = NULL;
	for(vector<HMONITOR>::iterator i = monitors.begin();i != monitors.end();i ++)
	{
		if(CComObject<CPSLMonitor>::CreateInstance(&pMonitor) == S_OK)
		{
			pMonitor->Initialize((*i));
			m_coll.push_back(CComPtr<IPSLMonitor>(pMonitor));
		}
	}
}

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

STDMETHODIMP CPSLMonitors::Update()
{
	PSL_BEGIN

	InternalUpdate();

	PSL_END
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Sibedge IT
Ireland Ireland
My online CV: cv.vitalytomilov.com

Comments and Discussions