Click here to Skip to main content
15,886,724 members
Articles / Programming Languages / Visual Basic 6

Professional System Library: Introduction

Rate me:
Please Sign up or sign in to vote.
4.84/5 (93 votes)
22 Nov 2010CPOL14 min read 191.2K   3.4K   232  
A simplified and unified way for accessing most frequently used information about Process, System, and Environment.
// PSLSystem.cpp : Implementation of CPSLSystem

#include "stdafx.h"
#include "PSLSystem.h"

CPSLSystem::CPSLSystem()
{
}

HRESULT CPSLSystem::FinalConstruct()
{
	return S_OK;
}

void CPSLSystem::FinalRelease()
{
}

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

STDMETHODIMP CPSLSystem::get_Hardware(IPSLHardware ** ppValue)
{
	PSL_BEGIN

	*ppValue = m_Hardware;
	
	PSL_END
}

STDMETHODIMP CPSLSystem::get_Software(IPSLSoftware ** ppValue)
{
	PSL_BEGIN

	*ppValue = m_Software;
	
	PSL_END
}

STDMETHODIMP CPSLSystem::get_Network(IPSLNetwork ** ppValue)
{
	PSL_BEGIN

	*ppValue = m_Network;
	
	PSL_END
}

STDMETHODIMP CPSLSystem::get_Process(IPSLCurrentProcess ** ppValue)
{
	PSL_BEGIN

	*ppValue = m_Process;
	
	PSL_END
}

STDMETHODIMP CPSLSystem::get_Security(IPSLSecurity ** ppValue)
{
	PSL_BEGIN

	*ppValue = m_Security;
	
	PSL_END
}

STDMETHODIMP CPSLSystem::get_Tools(IPSLTools ** ppValue)
{
	PSL_BEGIN

	*ppValue = m_Tools;
	
	PSL_END
}

/*
.NET clients should use type COMException when handling the
exception, because it contains ErrorCode that's missing in
type Exception. That ErrorCode is the one to be passed into
this method for translation.
*/
STDMETHODIMP CPSLSystem::DecodeException(HRESULT ErrorCode, PSLException * pValue)
{
	PSL_BEGIN

	long lError = HRESULT_CODE(ErrorCode) - COM_ERROR_BASE;
	if(lError >= EX_MIN && lError <= EX_MAX)
		*pValue = static_cast<PSLException>(lError);
	else
		*pValue = exInvalid;

	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