Click here to Skip to main content
15,881,852 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 128K   2.6K   174  
Access detailed information about the current process the easiest way.
// PSLCurrentProcess.h : Declaration of the CPSLCurrentProcess

#pragma once
#include "resource.h"       // main symbols
#include "GUIDs.h"
#include "AutoObject.h"
#include "PSLExceptions.h"
#include "ProSysLib_i.h"

#include "PSLModuleVersion.h"
#include "PSLProcessMemory.h"
#include "PSLEnvironmentVars.h"
#include "PSLProcessIO.h"
#include "PSLThreads.h"
#include "PSLWindows.h"
#include "PSLCmdParams.h"
#include "PSLModules.h"

class ATL_NO_VTABLE CPSLCurrentProcess:
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CPSLCurrentProcess, &CLSID_PSLCurrentProcess>,
	public IDispatchImpl<IPSLCurrentProcess, &IID_IPSLCurrentProcess, &LIBID_ProSysLib, PSL_HiVersion, PSL_LoVersion>,
	public CPSLException<&CLSID_PSLCurrentProcess, &IID_IPSLCurrentProcess>
{

public:

	CPSLCurrentProcess();

BEGIN_COM_MAP(CPSLCurrentProcess)
	COM_INTERFACE_ENTRY(IPSLCurrentProcess)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	DECLARE_PROTECT_FINAL_CONSTRUCT()
	HRESULT FinalConstruct();
	void FinalRelease();

////////////////////////////
// Interface Implementation:
////////////////////////////

	STDMETHOD(get_ProcessID)(long * pValue);
	STDMETHOD(get_ConsoleWnd)(VARIANT * pValue);
	STDMETHOD(get_FileName)(BSTR * pValue);
	STDMETHOD(get_FilePath)(BSTR * pValue);
	STDMETHOD(get_FileDir)(BSTR * pValue);
	STDMETHOD(get_CurrentDir)(BSTR * pValue);
	STDMETHOD(put_CurrentDir)(BSTR newValue);
	STDMETHOD(get_Created)(DATE * pValue);
	STDMETHOD(get_Is64Bit)(VARIANT_BOOL * pValue);
	STDMETHOD(get_IsDebugged)(VARIANT_BOOL * pValue);
	STDMETHOD(get_HandleCount)(long * pValue);
	STDMETHOD(get_GDICount)(long * pValue);
	STDMETHOD(get_USERCount)(long * pValue);
	STDMETHOD(get_ShutdownLevel)(long * pValue);
	STDMETHOD(put_ShutdownLevel)(long newValue);
	STDMETHOD(get_ShutdownFlags)(long * pValue);
	STDMETHOD(put_ShutdownFlags)(long newValue);
	STDMETHOD(get_Priority)(PSLProcessPriority * pValue);
	STDMETHOD(put_Priority)(PSLProcessPriority newValue);
	STDMETHOD(get_AffinityMask)(VARIANT * pValue);
	STDMETHOD(put_AffinityMask)(VARIANT newValue);
	STDMETHOD(get_Memory)(IPSLProcessMemory ** ppValue);
	STDMETHOD(get_IO)(IPSLProcessIO ** ppValue);
	STDMETHOD(get_EnvVars)(IPSLEnvironmentVars ** ppValue);
	STDMETHOD(get_Modules)(IPSLModules ** ppValue);
	STDMETHOD(get_Version)(IPSLModuleVersion ** ppValue);
	STDMETHOD(get_Commands)(IPSLCmdParams ** ppValue);
	STDMETHOD(get_Threads)(IPSLThreads ** ppValue);
	STDMETHOD(get_Windows)(IPSLWindows ** ppValue);
	
private:

	// Fixed values for the process:
	DWORD m_dwProcessID;	
	_bstr_t m_sFilePath;
	_bstr_t m_sFileDir;
	_bstr_t m_sFileName;
	DATE m_Created;

	CAutoObject<CPSLModuleVersion> m_Version;
	CAutoObject<CPSLProcessMemory> m_Memory;
	CAutoObject<CPSLProcessIO> m_ProcessIO;
	CAutoObject<CPSLEnvironmentVars> m_EnvVars;
	CAutoObject<CPSLCmdParams> m_Commands;
	CAutoObject<CPSLModules> m_Modules;
	CAutoObject<CPSLThreads> m_Threads;
	CAutoObject<CPSLWindows> m_Windows;
};

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