Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

ProSysLib: Dissecting the Process

, 22 Nov 2010
Access detailed information about the current process the easiest way.
ProcessInfo32_bin.zip
ProcessInfo64_bin.zip
ProcessInfo_bin.zip
ProSysLib_v0.9.zip
ProSysLib_v0.9
Bin
PSL32v0.9.dll
PSL64v0.9.dll
Help
Samples
C#2008
ProcessInfo
Properties
Settings.settings
ProcessViewer
Properties
Settings.settings
VB6
CPUInfo.exe
CPUInfo.frm
CPUInfo.frx
CPUInfo.vbp
CPUInfo.vbw
VC2008
Deployment
Src
mssccprj.scc
ProSysLib.def
ProSysLib.rgs
ProSysLib.vcproj.vspscc
ProSysLib.vssscc
PSLSystem.rgs
PSLv0.5Setup.zip
PSLv0.7Setup.zip
#pragma once

#include "ProSysLib_i.h"

////////////////////
// Exception codes;
//
#define EX_MIN				exGeneric			// Minimum exception code;

#define EX_GENERALFAILURE	exGeneric			// Generic or unknown Run-Time error occurred.
#define EX_INDEXOUTOFRANGE	exIndexOutOfRange	// Object index is outside the range of array bounds.
#define EX_NOTIMPLEMENTED	exNotImplemented	// Property or method was only declared but not implemented in your version of ProSysLib.
#define EX_LOWMEMORY		exLowMemory			// Failed to allocate enough memory to perform the operation.
#define EX_NOACCESS			exAccessDenied		// Insufficient Access Rights or Privileges to perform the operation.
#define EX_INVALIDPARAMETER	exInvalidParameter	// Value for property or a method parameter wasn�t recognized as valid.
#define EX_WMIERROR			exWMIError			// A WMI-specific error occurred.

#define EX_MAX				exWMIError			// Maximum exception code;

#define COM_ERROR_BASE		0x200				// Custom error code base as recommended by Microsoft;

#define DECLARE_EXCEPTION(A) const int E_##A = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, COM_ERROR_BASE + EX_##A);

///////////////////////////////////////
// Declaring all supported exceptions;
//
DECLARE_EXCEPTION(GENERALFAILURE)
DECLARE_EXCEPTION(INDEXOUTOFRANGE)
DECLARE_EXCEPTION(NOTIMPLEMENTED)
DECLARE_EXCEPTION(LOWMEMORY)
DECLARE_EXCEPTION(NOACCESS)
DECLARE_EXCEPTION(INVALIDPARAMETER)
DECLARE_EXCEPTION(WMIERROR)

HRESULT GetGlobalExitCode(PSLException exCode, const CLSID & clsID, const IID ID);

template<const CLSID * clsID, const IID * ID>
class CPSLException: public ISupportErrorInfo
{
public:

	CPSLException():m_exCode(exNone){}

	void SetException(PSLException exCode)
	{
		m_exCode = exCode;
	}

	HRESULT MakeException(PSLException exCode)
	{
		m_exCode = exCode;
		return GetGlobalExitCode(exCode, *clsID, *ID);
	}

protected:

	STDMETHODIMP InterfaceSupportsErrorInfo(REFIID riid)
	{
		static const IID* arr[] = {ID};
		for(int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++)
		{
			if(InlineIsEqualGUID(*arr[i], riid))
				return S_OK;
		}
		return S_FALSE;
	}

	HRESULT GetExitCode()
	{
		return GetGlobalExitCode(m_exCode, *clsID, *ID);
	}

private:

	PSLException m_exCode; // Exception Code;
};

#define PSL_BEGIN	SetException(exNone);try{
#define PSL_END	}catch(...){SetException(exGeneric);}return GetExitCode();

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)

Share

About the Author

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 22 Nov 2010
Article Copyright 2008 by Vitaly Tomilov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid