Chromium Code Reviews| Index: base/sys_info_win.cc |
| =================================================================== |
| --- base/sys_info_win.cc (revision 2544) |
| +++ base/sys_info_win.cc (working copy) |
| @@ -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,60 @@ |
| return rv; |
| } |
| +// static |
| +bool SysInfo::HasEnvironmentVariable(const char* var) { |
| + std::wstring wide_var = ASCIIToWide(std::string(var)); |
| + return GetEnvironmentVariable(wide_var.c_str(), NULL, 0) != 0; |
| +} |
| + |
| +// static |
| +std::wstring SysInfo::GetEnvironmentVariable(const char* var) { |
|
Mark Mentovai
2008/09/29 22:20:05
There's a problem here. On Windows, the platform
|
| + std::wstring wide_var = ASCIIToWide(std::string(var)); |
| + DWORD value_length = GetEnvironmentVariable(wide_var.c_str(), NULL, 0); |
| + if (value_length == 0) { |
| + return L""; |
| + } |
| + scoped_array<wchar_t> value(new wchar_t[value_length]); |
| + GetEnvironmentVariable(wide_var.c_str(), value.get(), value_length); |
| + return std::wstring(value); |
|
Mark Mentovai
2008/09/29 22:20:05
Changed this to 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 |