[ µwe||e ].Coding.Cpp.CSystemInfo

Banner

[Home] + [Coding] + [Downloads] + [Bookmarks]

C++

      [ Get a sample Snippet ]

[ CSystemInfo.hpp ]

//-------------------------------------------------------------------------------------//
//+++++++++++++++++[ System_Info_Class_Header ]++++++++++++++++++++++++++++++++++++++++//
//-------------------------------------------------------------------------------------//
//
//
// Last modi: 10.03.07 L.ey (µ~)
//
//
#ifndef _C_SYSINFO_H_
 #define _C_SYSINFO_H_

 #pragma hdrstop

 #pragma comment(lib, "netapi32.lib")

 #include <windows.h>
 #include <LMCONS.H>
 #include <lm.h>

 const char SI_STATUS_READY  = 0x01;
const char SI_STATUS_ERROR = 0x00;
const char SI_STATUS_PERROR = 0x02;

const char SI_OS_UK = 0x10;
const char SI_OS_NT = 0x01;
const char SI_OS_9X = 0x02;
const char SI_OS_3X = 0x03;

const char SI_LEVEL_UK = 0x10;
const char SI_LEVEL_ADMIN = 0x01;
const char SI_LEVEL_USER = 0x02;
const char SI_LEVEL_GUEST = 0x03;

//+++++++++++++++++[ class C_SystemInfo ]++++++++++++++++++++++++++++++++++++++++++++++// class C_SystemInfo
{
public://+++++++öffentlicher Zugriff+++++++// C_SystemInfo(); //->_Refresh(); ~C_SystemInfo(); DWORD _Refresh();

char _Get_OS_Version() const;
char _Get_UserLevel() const;

char* _Get_psComputerName() const;
char* _Get_psUserName() const;

char* _Get_psSystemPath() const;
char* _Get_psWindowsPath() const;

POINT* _Get_pScreen() const;
POINT* _Get_pBorderSize() const;
RECT* _Get_pTaskBar() const;
RECT* _Get_pWorkArea() const;

char _Get_XP_Theme() const;
char _Get_XP_Theme_Global() const;

private://++++++privater Zugriff+++++++++++// OSVERSIONINFO _WinVersionInfo; char _OS_Version;
int _VersionStatus;

char _UserLevel;

char* _psComputerName;
char _ComputerNameStatus;

char* _psUserName;
char _UserNameStatus;

char* _psSystemPath;
char _SystemPathStatus;

char* _psWindowsPath;
char _WindowsPathStatus;

POINT _Screen;
POINT* _pScreen;
char _ScreenStatus;

POINT _BorderSize;
POINT* _pBorderSize;
char _BorderSizeStatus;

RECT _TaskbarRect;
RECT* _pTaskbarRect;
char _TaskbarRectStatus;

RECT _Workarea;
RECT* _pWorkarea;
char _WorkareaStatus;

char _XP_Theme_Active;
char _XP_Theme_Global_Active;

protected://++++geschützter Zugriff++++++++// }; #endif // _C_SYSINFO_H_

[ CSystemInfo.cpp ]
//-------------------------------------------------------------------------------------//
//+++++++++++++++++[ System_Info_Class_Source ]++++++++++++++++++++++++++++++++++++++++//
//-------------------------------------------------------------------------------------//

#include "C_SystemInfo.hpp"

/////////////////////////////////////////////////////////////////////////////////////////
////////  [Konstructor]  ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
C_SystemInfo::C_SystemInfo()
{
   _psComputerName = 0x00;
_psUserName = 0x00;
_psSystemPath = 0x00;
_psWindowsPath = 0x00;

_pScreen = &_Screen;
_pBorderSize = &_BorderSize;
_pTaskbarRect = &_TaskbarRect;
_pWorkarea = &_Workarea;

//_WinVersionInfo-------------------------------------------------- // _WinVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

if(GetVersionEx(&_WinVersionInfo))
{
_VersionStatus = SI_STATUS_READY;

switch(_WinVersionInfo.dwPlatformId)
{
case VER_PLATFORM_WIN32_WINDOWS: _OS_Version = SI_OS_9X; break;
case VER_PLATFORM_WIN32_NT: _OS_Version = SI_OS_NT; break;
case VER_PLATFORM_WIN32s: _OS_Version = SI_OS_3X; break;
default: _OS_Version = SI_OS_UK; break;
}
}
else _VersionStatus = GetLastError();

_psComputerName = new char[MAX_COMPUTERNAME_LENGTH + 1];
_psUserName = new char[UNLEN + 1];

_psSystemPath = new char[MAX_PATH + 1];
_psWindowsPath = new char[MAX_PATH + 1];

//-------------------------------------------------- // _Refresh(); } ///////////////////////////////////////////////////////////////////////////////////////// //////// [Destructor] ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// C_SystemInfo::~C_SystemInfo() { if(_psComputerName) delete [] _psComputerName;
if(_psUserName) delete [] _psUserName;
if(_psSystemPath) delete [] _psSystemPath;
if(_psWindowsPath) delete [] _psWindowsPath;
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Refresh] /////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// DWORD C_SystemInfo::_Refresh()
{
DWORD NameLen = 0;
APPBARDATA tAPPBARDATA;

//Fill _pComputerName-------------------------------------------------- // NameLen = MAX_COMPUTERNAME_LENGTH + 1;

if(_psComputerName)
{
if(GetComputerName(_psComputerName, &NameLen))
{
_ComputerNameStatus = SI_STATUS_READY;
}
else _ComputerNameStatus = SI_STATUS_ERROR;
}
else _ComputerNameStatus = SI_STATUS_PERROR;


//Fill _pUserName-------------------------------------------------- // NameLen = UNLEN + 1;

if(_psUserName)
{
if(GetUserName(_psUserName, &NameLen))
{
_UserNameStatus = SI_STATUS_READY;
}
else _UserNameStatus = SI_STATUS_ERROR;
}
else _UserNameStatus = SI_STATUS_PERROR;


//Fill _pWindowsPath-------------------------------------------------- // NameLen = MAX_PATH + 1;

if(_psWindowsPath)
{
if(GetWindowsDirectory(_psWindowsPath, NameLen))
{
_WindowsPathStatus = SI_STATUS_READY;
}
else _WindowsPathStatus = SI_STATUS_ERROR;
}
else _WindowsPathStatus = SI_STATUS_PERROR;


//Fill _pSystemPath-------------------------------------------------- // NameLen = MAX_PATH + 1;

if(_psSystemPath)
{
if(GetSystemDirectory(_psSystemPath, NameLen))
{
_SystemPathStatus = SI_STATUS_READY;
}
else _SystemPathStatus = SI_STATUS_ERROR;
}
else _SystemPathStatus = SI_STATUS_PERROR;


//Fill _Screen-------------------------------------------------- // _Screen.x = GetSystemMetrics(SM_CXSCREEN); _Screen.y = GetSystemMetrics(SM_CYSCREEN); if( (_Screen.x == 0) || (_Screen.y == 0) )
{
_ScreenStatus = SI_STATUS_ERROR;
}
else _ScreenStatus = SI_STATUS_READY;


//Fill BorderSize-------------------------------------------------- // _BorderSize.x = GetSystemMetrics(SM_CXEDGE); _BorderSize.y = GetSystemMetrics(SM_CYEDGE); if( (_BorderSize.x == 0) || (_BorderSize.y == 0) )
{
_BorderSizeStatus = SI_STATUS_ERROR;
}
else _BorderSizeStatus = SI_STATUS_READY;


//Fill _TaskbarRect-------------------------------------------------- // tAPPBARDATA.cbSize = sizeof(APPBARDATA);

SHAppBarMessage(ABM_GETTASKBARPOS, &tAPPBARDATA);

_TaskbarRect.bottom = tAPPBARDATA.rc.bottom;
_TaskbarRect.left = tAPPBARDATA.rc.left;
_TaskbarRect.right = tAPPBARDATA.rc.right;
_TaskbarRect.top = tAPPBARDATA.rc.top;

_TaskbarRectStatus = SI_STATUS_READY;


//Fill _Workarea-------------------------------------------------- // if(SystemParametersInfo(SPI_GETWORKAREA, 0, &_Workarea, 0))
{
_WorkareaStatus = SI_STATUS_READY;
}
else _WorkareaStatus = SI_STATUS_ERROR;


//Fill _UserLevel-------------------------------------------------- // DWORD result = 0;
wchar_t sUser[256] = {0};
USER_INFO_1* pUserInfo = 0x00;
DWORD size = 0;

size = sizeof(sUser);

GetUserNameW(sUser, &size);

result = NetUserGetInfo( NULL, sUser, 1, (byte**) &pUserInfo );

if(result == NERR_Success)
{
if(pUserInfo->usri1_priv == USER_PRIV_ADMIN)
{
_UserLevel = SI_LEVEL_ADMIN;
}
else if(pUserInfo->usri1_priv == USER_PRIV_USER)
{
_UserLevel = SI_LEVEL_USER;
}
else if(pUserInfo->usri1_priv == USER_PRIV_GUEST)
{
_UserLevel = SI_LEVEL_GUEST;
}
else { _UserLevel = SI_LEVEL_UK; } NetApiBufferFree(pUserInfo); } else _UserLevel = SI_LEVEL_UK;


//Fill pIsThemeActive-------------------------------------------------- // _XP_Theme_Global_Active = 0;
_XP_Theme_Active = 0;

if(_VersionStatus == SI_STATUS_READY)
{
if( (_WinVersionInfo.dwMajorVersion >= 5) && (_WinVersionInfo.dwMinorVersion >= 1) )
{
//Windows XP detected typedef BOOL WINAPI IsAppThemed();
typedef BOOL WINAPI IsThemeActive();

IsAppThemed* pIsAppThemed = NULL;
IsThemeActive* pIsThemeActive = NULL;

HMODULE hMod = LoadLibrary("uxtheme.dll");

if(hMod)
{
pIsAppThemed = GetProcAddress(hMod, "IsAppThemed");
pIsThemeActive = GetProcAddress(hMod, "IsThemeActive");

if(pIsAppThemed && pIsThemeActive)
{
if(pIsThemeActive()) _XP_Theme_Global_Active = 1;
if(pIsAppThemed()) _XP_Theme_Active = 1;
}
}
}
}

return(1);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_OS_Version] //////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// char C_SystemInfo::_Get_OS_Version() const { if(_VersionStatus == SI_STATUS_READY) return(_OS_Version);
return(SI_STATUS_ERROR);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_UserLevel] ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// char C_SystemInfo::_Get_UserLevel() const { return(_UserLevel);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_ComputerName] ////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// char* C_SystemInfo::_Get_psComputerName() const { if(_ComputerNameStatus == SI_STATUS_READY) return(_psComputerName);
return(SI_STATUS_ERROR);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_UserName] ////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// char* C_SystemInfo::_Get_psUserName() const { if(_UserNameStatus == SI_STATUS_READY) return(_psUserName);
return(SI_STATUS_ERROR);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_SystemPath] //////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// char* C_SystemInfo::_Get_psSystemPath() const { if(_SystemPathStatus == SI_STATUS_READY) return(_psSystemPath);
return(SI_STATUS_ERROR);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_WindowsPath] /////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// char* C_SystemInfo::_Get_psWindowsPath() const { if(_WindowsPathStatus == SI_STATUS_READY) return(_psWindowsPath);
return(SI_STATUS_ERROR);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_Screen] //////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// POINT* C_SystemInfo::_Get_pScreen() const { if(_ScreenStatus == SI_STATUS_READY) return(_pScreen);
return(0);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_BorderSize] //////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// POINT* C_SystemInfo::_Get_pBorderSize() const { if(_BorderSizeStatus == SI_STATUS_READY) return(_pBorderSize);
return(0);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_TaskBar] /////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// RECT* C_SystemInfo::_Get_pTaskBar() const { if(_TaskbarRectStatus == SI_STATUS_READY) return(_pTaskbarRect);
return(0);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_WorkArea] ////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// RECT* C_SystemInfo::_Get_pWorkArea() const { if(_WorkareaStatus == SI_STATUS_READY) return(_pWorkarea);
return(0);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_XP_Theme] ////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// char C_SystemInfo::_Get_XP_Theme() const { return(_XP_Theme_Active);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_XP_Theme_Global] /////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// char C_SystemInfo::_Get_XP_Theme_Global() const { return(_XP_Theme_Global_Active);
}

[Сê] `.´ [µwe||e]
1
Hosted by www.Geocities.ws

1