blob: 43b9bff7d84b7d681ec9273b4585259e374de09b (
plain)
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
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/env_util.h"
#include "base/basictypes.h"
#include "base/logging.h"
static const DWORDLONG kBytesPerMegabyte = 1048576;
namespace env_util {
std::string GetOperatingSystemName() {
return "Windows";
}
std::string GetOperatingSystemVersion() {
OSVERSIONINFO info = {0};
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&info);
char result[20];
memset(result, 0, arraysize(result));
_snprintf_s(result, arraysize(result),
"%lu.%lu", info.dwMajorVersion, info.dwMinorVersion);
return std::string(result);
}
int GetPhysicalMemoryMB() {
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
if (::GlobalMemoryStatusEx(&status))
return static_cast<int>(status.ullTotalPhys / kBytesPerMegabyte);
NOTREACHED() << "GlobalMemoryStatusEx failed.";
return 0;
}
std::string GetCPUArchitecture() {
// TODO: Make this vary when we support any other architectures.
return "x86";
}
void GetPrimaryDisplayDimensions(int* width, int* height) {
if (width)
*width = GetSystemMetrics(SM_CXSCREEN);
if (height)
*height = GetSystemMetrics(SM_CYSCREEN);
}
int GetDisplayCount() {
return GetSystemMetrics(SM_CMONITORS);
}
} // namespace env_util
|