-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOSInformations.cpp
More file actions
146 lines (107 loc) · 2.88 KB
/
OSInformations.cpp
File metadata and controls
146 lines (107 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// OSInformations.cpp: implementation of the COSInformations class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CPUBench2004.h"
#include "OSInformations.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#define CMONITORS 80
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
COSInformations::COSInformations()
{
OSVERSIONINFO OSver;
OSVERSIONINFO OSverEx;
OSver.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
OSverEx.dwOSVersionInfoSize=sizeof(OSVERSIONINFOEX);
GetVersionEx(&OSver); //informazioni sull'OS
//rilevo la versione dell'OS
switch(OSver.dwMajorVersion) {
case 3:
m_OSName="Microsoft Windows 95";
break;
case 4:
switch(OSver.dwMinorVersion) {
case 00:
m_OSName="Microsoft Windows NT 4.0";
break;
case 10:
m_OSName="Microsoft Windows 98";
break;
case 90:
m_OSName="Microsoft Windows ME";
break;
default:
m_OSName="MS Windows 4.0";
}
break;
case 5:
GetVersionEx(&OSverEx);
BuildNumber=OSverEx.dwBuildNumber;
OSServicePack=OSverEx.szCSDVersion;
if(OSServicePack == "") OSServicePack="none installed";
switch(OSver.dwMinorVersion) {
case 0:
m_OSName="Microsoft Windows 2000";
break;
case 1:
m_OSName="Microsoft Windows XP";
break;
default:
m_OSName="Next generation windows";
break;
}
break;
default:
m_OSName="Next Generation Windows";
}
m_MajorVer=OSverEx.dwMajorVersion;
m_MinorVer=OSverEx.dwMinorVersion;
char* str=new char[128];
DWORD size=128;
::GetComputerName(str,&size);
PCName=str;
size=128;
::GetUserName(str,&size);
UserName=str;
::GetSystemDirectory(str,128);
OSDirectory=str;
::GetWindowsDirectory(str,128);
WindowsDirectory=str;
switch(GetSystemMetrics(SM_CLEANBOOT)) {
case 0:
SysBootStatus="Normal Boot";
break;
case 1:
SysBootStatus="Fail Safe boot";
break;
case 2:
SysBootStatus="Fail Safe with Network";
break;
}
NumOfMonitors=GetSystemMetrics(CMONITORS);
NetworkStatus=GetSystemMetrics(SM_NETWORK) & 1 ? "Detected" : "Not Detected";
bool bMode;
SystemParametersInfo(SPI_GETLOWPOWERACTIVE,0,&bMode,0);
StandByMode= bMode ? "Enabled" : "Disabled";
if(bMode){
SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,0,&StandByTimeout,0);
CString strTO;
strTO.Format(" (at %d minute(s))",StandByTimeout/60);
StandByMode+=strTO;
}
else StandByTimeout=0;
ScreenWidth=GetSystemMetrics(SM_CXSCREEN);
ScreenHeigth=GetSystemMetrics(SM_CYSCREEN);
CDC dc;
dc.CreateCompatibleDC(NULL); //dev dc
ScreenColors=GetDeviceCaps(dc,BITSPIXEL);
}
COSInformations::~COSInformations()
{
}