|
#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.