diff options
Diffstat (limited to 'base/sys_info_win.cc')
-rw-r--r-- | base/sys_info_win.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc index 2d3c203..4d52c4a 100644 --- a/base/sys_info_win.cc +++ b/base/sys_info_win.cc @@ -7,6 +7,8 @@ #include <windows.h> #include "base/logging.h" +#include "base/scoped_ptr.h" +#include "base/string_util.h" namespace base { @@ -44,4 +46,58 @@ int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) { return rv; } +// static +bool SysInfo::HasEnvVar(const wchar_t* var) { + return GetEnvironmentVariable(var, NULL, 0) != 0; +} + +// static +std::wstring SysInfo::GetEnvVar(const wchar_t* var) { + DWORD value_length = GetEnvironmentVariable(var, NULL, 0); + if (value_length == 0) { + return L""; + } + scoped_array<wchar_t> value(new wchar_t[value_length]); + GetEnvironmentVariable(var, value.get(), value_length); + return std::wstring(value.get()); +} + +// static +std::string SysInfo::OperatingSystemName() { + return "Windows NT"; +} + +// static +std::string SysInfo::OperatingSystemVersion() { + OSVERSIONINFO info = {0}; + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&info); + + return StringPrintf("%lu.%lu", info.dwMajorVersion, info.dwMinorVersion); +} + +// TODO: Implement OperatingSystemVersionComplete, which would include +// patchlevel/service pack number. See chrome/browser/views/bug_report_view.cc, +// BugReportView::SetOSVersion. + +// static +std::string SysInfo::CPUArchitecture() { + // TODO: Make this vary when we support any other architectures. + return "x86"; +} + +// static +void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) { + if (width) + *width = GetSystemMetrics(SM_CXSCREEN); + + if (height) + *height = GetSystemMetrics(SM_CYSCREEN); +} + +// static +int SysInfo::DisplayCount() { + return GetSystemMetrics(SM_CMONITORS); +} + } // namespace base |