Click here to Skip to main content
12,400,830 members (54,411 online)
Click here to Skip to main content

Stats

73.4K views
1.8K downloads
170 bookmarked
Posted

ProSysLib: Dissecting the Process

, 22 Nov 2010 CPOL
Access detailed information about the current process the easiest way.
ProcessInfo.exe
ProSysLib.dll
Interop.ProSysLib.dll
Interop.ProSysLib.dll
ProcessInfo.exe
ProSysLib.dll
PSL64v0.9.dll
Interop.ProSysLib.dll
ProcessInfo.exe
PSL32v0.9.dll
ProSysLib_v0.9
Bin
PSL32v0.9.dll
PSL64v0.9.dll
Help
Samples
C#2008
ProcessInfo
Properties
ProcessViewer
Properties
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.exe
PSLv0.7Setup.exe
// PSLCmdParam.cpp : Implementation of CPSLCmdParam

#include "stdafx.h"
#include "PSLCmdParam.h"

CPSLCmdParam::CPSLCmdParam()
{
	m_sName = _T("");
	m_sValue = _T("");
	m_sCommand = _T("");
}

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

void CPSLCmdParam::FinalRelease()
{
}

/*
Command name must always start with either '/' or '-';
Otherwise, this is not a command, and goes into Value;

The command name must have at least one symbol in it;

When values are within quotes, quotes are removed;
Value is truncated to contain no leading spaces;
*/
void CPSLCmdParam::Initialize(LPCTSTR sCommand)
{
	m_sCommand = sCommand;

	long L = (long)_tcslen(sCommand);
	tstring buffer;
	buffer.resize(L + 1);
	TCHAR symbol = sCommand[0];
	int idx = 0;
	if(symbol == '/' || symbol == '-')
	{
		// This looks like a command;
		if(L < 2)
			return; // Nothing;
		bool bHasValue = false;
		idx ++;
		while(idx < L)
		{
			symbol = sCommand[idx];
			if(symbol == ' ')
			{
				if(idx > 1)
				{
					_tcsncpy_s((LPTSTR)buffer.c_str(), L + 1, sCommand + 1, idx);
					m_sName = buffer.c_str();
				}
				break;
			}
			if(symbol == '"')
				break;
			if(symbol == ':' || symbol == '=')
			{
				if(idx > 1)
				{
					_tcsncpy_s((LPTSTR)buffer.c_str(), L + 1, sCommand + 1, idx - 1);
					m_sName = buffer.c_str();
				}
				idx ++;
				break;
			}
			idx ++;
			if(idx == L && idx > 1)
			{
				_tcsncpy_s((LPTSTR)buffer.c_str(), L + 1, sCommand + 1, idx - 1);
				m_sName = buffer.c_str();
			}
		}
	}
	if(idx >= L)
		return;
	if(sCommand[idx] == '"')
		idx ++;
	int start = idx;
	while(idx < L)
	{
		if(sCommand[idx] == '"')
			break;
		idx ++;
	}
	_tcsncpy_s((LPTSTR)buffer.c_str(), L + 1, sCommand + start, idx - start);
	trim(buffer);
	m_sValue = buffer.c_str();
}

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

STDMETHODIMP CPSLCmdParam::get_Name(BSTR * pValue)
{
	PSL_BEGIN

	*pValue = m_sName.copy();
	
	PSL_END
}

STDMETHODIMP CPSLCmdParam::get_Value(BSTR * pValue)
{
	PSL_BEGIN

	*pValue = m_sValue.copy();
	
	PSL_END
}

STDMETHODIMP CPSLCmdParam::get_Command(BSTR * pValue)
{
	PSL_BEGIN

	*pValue = m_sCommand.copy();
	
	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)

Share

About the Author

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

You may also be interested in...

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