@@ -121,19 +121,11 @@ static BOOL IsWow64()
121
121
return bIsWow64;
122
122
}
123
123
124
- std::string PlatformUtils::sysinfo ( bool extended )
124
+ std::string platformid_sysinfo (OSVERSIONINFOEX &osinfo )
125
125
{
126
- std::string result;
127
-
128
- OSVERSIONINFOEX osinfo;
129
- osinfo.dwOSVersionInfoSize = sizeof (osinfo);
130
-
131
- if (GetVersionExEx (&osinfo) == 0 ) {
132
- result += " Unknown Windows" ;
133
- } else {
134
- unsigned int version = osinfo.dwMajorVersion * 1000 + osinfo.dwMinorVersion ;
135
- if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
136
- switch (version) {
126
+ std::string result (" " );
127
+ unsigned int version = osinfo.dwMajorVersion * 1000 + osinfo.dwMinorVersion ;
128
+ switch (version) {
137
129
case 5000 :
138
130
result += " Windows 2000" ;
139
131
break ;
@@ -159,52 +151,67 @@ std::string PlatformUtils::sysinfo(bool extended)
159
151
default :
160
152
result += " Unknown Windows" ;
161
153
break ;
154
+ }
155
+
156
+ if (osinfo.wServicePackMajor > 0 ) {
157
+ boost::format fmtServicePack;
158
+ if (osinfo.wServicePackMinor == 0 ) {
159
+ fmtServicePack = boost::format (" SP%d" );
160
+ fmtServicePack % osinfo.wServicePackMajor ;
161
+ } else {
162
+ fmtServicePack = boost::format (" SP%d.%d" );
163
+ fmtServicePack % osinfo.wServicePackMajor % osinfo.wServicePackMinor ;
162
164
}
163
-
164
- if (osinfo.wServicePackMajor > 0 ) {
165
- boost::format fmtServicePack;
166
- if (osinfo.wServicePackMinor == 0 ) {
167
- fmtServicePack = boost::format (" SP%d" );
168
- fmtServicePack % osinfo.wServicePackMajor ;
169
- } else {
170
- fmtServicePack = boost::format (" SP%d.%d" );
171
- fmtServicePack % osinfo.wServicePackMajor % osinfo.wServicePackMinor ;
172
- }
173
- result += fmtServicePack.str ();
174
- }
175
-
176
- boost::format fmt (" (v%d.%d.%d.%d)" );
177
- fmt % osinfo.dwMajorVersion % osinfo.dwMinorVersion % osinfo.wServicePackMajor % osinfo.wServicePackMinor ;
178
- result += fmt.str ();
165
+ result += fmtServicePack.str ();
166
+ }
167
+
168
+ boost::format fmt (" (v%d.%d.%d.%d)" );
169
+ fmt % osinfo.dwMajorVersion % osinfo.dwMinorVersion % osinfo.wServicePackMajor % osinfo.wServicePackMinor ;
170
+ result += fmt.str ();
171
+ return result;
172
+ }
173
+
174
+ std::string PlatformUtils::sysinfo (bool extended)
175
+ {
176
+ std::string result;
177
+
178
+ OSVERSIONINFOEX osinfo;
179
+ osinfo.dwOSVersionInfoSize = sizeof (osinfo);
180
+
181
+ if (GetVersionExEx (&osinfo) == 0 ) {
182
+ result += " Unknown Windows" ;
179
183
} else {
180
- boost::format fmt (" Unknown Windows (dwPlatformId = %d, dwMajorVersion = %d, dwMinorVersion = %d" );
181
- fmt % osinfo.dwPlatformId % osinfo.dwMajorVersion % osinfo.dwMinorVersion ;
182
- result += fmt.str ();
183
- }
184
+ if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
185
+ result += platformid_sysinfo ( osinfo );
186
+ } else {
187
+ boost::format fmt (" Unknown Windows (dwPlatformId = %d, dwMajorVersion = %d, dwMinorVersion = %d" );
188
+ fmt % osinfo.dwPlatformId % osinfo.dwMajorVersion % osinfo.dwMinorVersion ;
189
+ result += fmt.str ();
190
+ }
184
191
}
185
-
192
+
186
193
SYSTEM_INFO systeminfo;
187
194
bool isWow64 = IsWow64 ();
188
195
if (isWow64) {
189
196
GetNativeSystemInfo (&systeminfo);
190
197
} else {
191
- GetSystemInfo (&systeminfo);
198
+ GetSystemInfo (&systeminfo);
192
199
}
193
-
200
+
194
201
if (extended) {
195
202
int numcpu = systeminfo.dwNumberOfProcessors ;
196
203
boost::format fmt (" %d CPU%s%s" );
197
204
fmt % numcpu % (numcpu > 1 ? " s" : " " ) % (isWow64 ? " WOW64" : " " );
198
205
result += fmt.str ();
199
-
206
+
200
207
MEMORYSTATUSEX memoryinfo;
201
208
memoryinfo.dwLength = sizeof (memoryinfo);
202
209
if (GlobalMemoryStatusEx (&memoryinfo) != 0 ) {
203
210
result += " " ;
204
211
result += PlatformUtils::toMemorySizeString (memoryinfo.ullTotalPhys , 2 );
205
212
result += " RAM" ;
206
213
}
207
- }
214
+ }
208
215
209
216
return result;
210
217
}
0 commit comments