Click here to Skip to main content
15,897,371 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 129.3K   2.6K   174  
Access detailed information about the current process the easiest way.
#include "stdafx.h"
#include "resource.h"
#include "ProSysLib_i.h"
#include "ProSysModule.h"
#include "dlldatax.h"
#include "AutoObject.h"

CProSysLibModule _Module;

CProSysLibModule::CProSysLibModule()
{
	::InitializeCriticalSection(&m_cs);

	m_hResInstance = NULL;

	m_bWinSockets = false;
	DWORD dwOSVersion = ::GetVersion();
	DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwOSVersion)));
    DWORD dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwOSVersion)));
	m_bWin2000 = (dwMajorVersion == 5 && !dwMinorVersion);
}

CProSysLibModule::~CProSysLibModule()
{
	::DeleteCriticalSection(&m_cs);
}

bool CProSysLibModule::IsWin2000()
{
	return m_bWin2000;
}

bool CProSysLibModule::InitWinSockets()
{
	CCritSecLock cs(m_cs);

	if(m_bWinSockets)
		return true; // Already initialized;

	// Initialize Windows Socket Support;
	WORD wVersionRequested = MAKEWORD(2, 2);
	WSADATA wsaData;
	m_bWinSockets =::WSAStartup(wVersionRequested, &wsaData)?false:true;

	return m_bWinSockets;
}

void CProSysLibModule::SetResourceInstance(HINSTANCE hInstance)
{
	m_hResInstance = hInstance;
}

HINSTANCE CProSysLibModule::GetResourceInstance()
{
	return m_hResInstance;
}

void CProSysLibModule::InitLibId()
{
	CAtlModule::m_libid = LIBID_ProSysLib;
}

void CProSysLibModule::OnModuleStart()
{
	// This is where we can initialize global objects;
}

void CProSysLibModule::OnModuleTerminate()
{
	// This is where we can uninitialize global objects;
	//

	// Shutting down WinSockets, if they were in use:
	CCritSecLock cs(m_cs);
	if(m_bWinSockets)
	{
		::WSACleanup();
		m_bWinSockets = false;
	}
	cs.Unlock();

}

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