summaryrefslogtreecommitdiffstats
path: root/chrome/common/env_util.cc
blob: 3af22a625f34f052e8b98215828dedf1a8a4a9b0 (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
// 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"

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);
}

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