Click here to Skip to main content
12,350,971 members (33,292 online)
Click here to Skip to main content

Stats

72.9K 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
// PSLNetwork.cpp : Implementation of CPSLNetwork

#include "stdafx.h"
#include "PSLNetwork.h"
#include "PSLIPv4.h"
#include "PSLIPv6.h"
#include "ProSysModule.h"
#include <lm.h>

CPSLNetwork::CPSLNetwork()
{
	// Not needed yet!
	//_Module.InitWinSockets(); // Initialize WinSockets;

	tstring pcName;
	DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
	pcName.resize(dwSize);
	::GetComputerName((LPTSTR)pcName.c_str(), &dwSize);
	m_sPCName = pcName.c_str();
}

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

void CPSLNetwork::FinalRelease()
{
}

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

STDMETHODIMP CPSLNetwork::get_PCName(BSTR * pValue)
{
	PSL_BEGIN

	*pValue = m_sPCName.copy();
	
	PSL_END
}

STDMETHODIMP CPSLNetwork::get_DomainName(BSTR * pValue)
{
	PSL_BEGIN

	_bstr_t name(_T(""));
	LPWKSTA_INFO_100 pBuffer = NULL;
	DWORD dwStatus = ::NetWkstaGetInfo(NULL, 100, (LPBYTE*)&pBuffer);
	if(dwStatus == NERR_Success)
	{
		name = pBuffer->wki100_langroup;
		::NetApiBufferFree(pBuffer);
	}
	else
		if(dwStatus == ERROR_ACCESS_DENIED)
			return MakeException(exAccessDenied);

	*pValue = name.copy();

	PSL_END
}

STDMETHODIMP CPSLNetwork::IPv4FromString(BSTR Address, IPSLIPv4 ** ppValue)
{
	PSL_BEGIN

	*ppValue = NULL;
	CComObject<CPSLIPv4> * pIPv4 = NULL;
	if(CComObject<CPSLIPv4>::CreateInstance(&pIPv4) == S_OK)
	{
		pIPv4->AddRef();
		bool bValid = true;
		if(Address)
		{
			_bstr_t sAddress(_T(""));
			if(Address)
				sAddress = Address;
			bValid = pIPv4->Initialize(sAddress, true);
		}
		if(bValid)
			*ppValue = CComPtr<IPSLIPv4>(pIPv4);
		else
		{
			pIPv4->Release();
			SetException(exInvalidParameter);
		}
	}

	PSL_END
}

STDMETHODIMP CPSLNetwork::IPv6FromString(BSTR Address, IPSLIPv6 ** ppValue)
{
	PSL_BEGIN

	*ppValue = NULL;
	CComObject<CPSLIPv6> * pIPv6 = NULL;
	if(CComObject<CPSLIPv6>::CreateInstance(&pIPv6) == S_OK)
	{
		pIPv6->AddRef();
		bool bValid = true;
		if(Address)
		{
			_bstr_t sAddress(_T(""));
			if(Address)
				sAddress = Address;
			bValid = pIPv6->Initialize(sAddress, true);
		}
		if(bValid)
			*ppValue = CComPtr<IPSLIPv6>(pIPv6);
		else
		{
			pIPv6->Release();
			SetException(exInvalidParameter);
		}
	}

	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.160621.1 | Last Updated 22 Nov 2010
Article Copyright 2008 by Vitaly Tomilov
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid