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 <string>
#include <sstream>
#include <iomanip>
#include <algorithm>

typedef basic_string<TCHAR, char_traits<TCHAR>, allocator<TCHAR> > tstring;
typedef basic_ostringstream<TCHAR, char_traits<TCHAR>, allocator<TCHAR> > otstringstream;
typedef basic_istringstream<TCHAR, char_traits<TCHAR>, allocator<TCHAR> > itstringstream;

void remove_char(tstring & s, TCHAR c);				// removes particular character;
void remove_chars(tstring & s, LPCTSTR symbols);	// removes set of characters;
void remove_repeat(tstring & s, TCHAR c);			// removes repeated character;

#define SPACES _T(" \t\r\n")

inline void trim_right(tstring & s, LPCTSTR delims = SPACES)
{
	s.erase(s.find_last_not_of(delims) + 1);
}

inline void trim_left(tstring & s, LPCTSTR delims = SPACES)
{
	s.erase(0, s.find_first_not_of(delims));
}

inline void trim(tstring & s, LPCTSTR delims = SPACES)
{
	trim_right(s, delims);
	trim_left(s, delims);
}

inline void make_upper(tstring & s)
{
	transform(s.begin(), s.end(), s.begin(), toupper);
}

inline void make_lower(tstring & s)
{
	transform(s.begin(), s.end(), s.begin(), tolower);
}

inline void shrink(tstring & s)
{
	s.resize(::_tcslen(s.c_str()));
}

inline void tohex(tstring & s, long value)
{
	otstringstream os;
	os << hex << value;
	s = os.str();
}

inline void toint(tstring & s, long value)
{
	otstringstream os;
	os << value;
	s = os.str();
}

// adds necessary c symbols in front of the converted
// hex number to make up n symbols in total;
inline void tohexfill(tstring & s, long value, long n, TCHAR c = '0')
{
	otstringstream os;
	os << setfill<TCHAR>(c) << setw(n) << hex << value;
	s = os.str();
}

// adds necessary c symbols in front of the converted
// integer number to make up n symbols in total;
inline void tointfill(tstring & s, long value, long n, TCHAR c = '0')
{
	otstringstream os;
	os << setfill<TCHAR>(c) << setw(n) << value;
	s = os.str();
}

template<class T>
inline bool fromhex(LPCTSTR s, T & value)
{
	value = 0;
	itstringstream is(s);
	return (is >> hex >> value)?true:false;
}

template<class T>
inline bool fromint(LPCTSTR s, T & value)
{
	value = 0;
	itstringstream is(s);
	return (is >> value)?true:false;
}

inline bool isvalidhex(LPCTSTR s, long minValue = 0, long MaxValue = 0xFFFFFFFF)
{
	long value;
	return fromhex(s, value) && value >= minValue && value <= MaxValue;
}

inline bool isvalidint(LPCTSTR s, long minValue = 0, long MaxValue = 0xFFFFFFFF)
{
	long value;
	return fromint(s, value) && value >= minValue && value <= MaxValue;
}

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)

About the Author

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

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