diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-15 01:59:15 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-15 01:59:15 +0000 |
commit | 935aa54d9a5e2e617c61c9f8dcea398768413443 (patch) | |
tree | 3df9ec9316cd4d5b7171e5c6c869a01d823cc507 /base/win | |
parent | 7d1f3348c26eda2d1656860c821d335bf94d4cda (diff) | |
download | chromium_src-935aa54d9a5e2e617c61c9f8dcea398768413443.zip chromium_src-935aa54d9a5e2e617c61c9f8dcea398768413443.tar.gz chromium_src-935aa54d9a5e2e617c61c9f8dcea398768413443.tar.bz2 |
Move windows version-related stuff out of base/win_util and into base/win/windows_version. Many files now only need to include this instead of all of win_util.
Remove a bunch of unused code from base/win_util. There was a surprising amount.
Replace the AppUserModel property key with the one from the SDK now that we use the Win7 SDK. Move GetLogonSessionOnlyDACL from win_util to ipc since it's only used in that one place.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/3823002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62694 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win')
-rw-r--r-- | base/win/windows_version.cc | 72 | ||||
-rw-r--r-- | base/win/windows_version.h | 34 |
2 files changed, 106 insertions, 0 deletions
diff --git a/base/win/windows_version.cc b/base/win/windows_version.cc new file mode 100644 index 0000000..a80688c --- /dev/null +++ b/base/win/windows_version.cc @@ -0,0 +1,72 @@ +// Copyright (c) 2010 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 "base/win/windows_version.h" + +#include <windows.h> + +#include "base/logging.h" + +namespace base { +namespace win { + +Version GetVersion() { + static bool checked_version = false; + static Version win_version = VERSION_PRE_2000; + if (!checked_version) { + OSVERSIONINFOEX version_info; + version_info.dwOSVersionInfoSize = sizeof version_info; + GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info)); + if (version_info.dwMajorVersion == 5) { + switch (version_info.dwMinorVersion) { + case 0: + win_version = VERSION_2000; + break; + case 1: + win_version = VERSION_XP; + break; + case 2: + default: + win_version = VERSION_SERVER_2003; + break; + } + } else if (version_info.dwMajorVersion == 6) { + if (version_info.wProductType != VER_NT_WORKSTATION) { + // 2008 is 6.0, and 2008 R2 is 6.1. + win_version = VERSION_2008; + } else { + if (version_info.dwMinorVersion == 0) { + win_version = VERSION_VISTA; + } else { + win_version = VERSION_WIN7; + } + } + } else if (version_info.dwMajorVersion > 6) { + win_version = VERSION_WIN7; + } + checked_version = true; + } + return win_version; +} + +void GetServicePackLevel(int* major, int* minor) { + DCHECK(major && minor); + static bool checked_version = false; + static int service_pack_major = -1; + static int service_pack_minor = -1; + if (!checked_version) { + OSVERSIONINFOEX version_info = {0}; + version_info.dwOSVersionInfoSize = sizeof(version_info); + GetVersionEx(reinterpret_cast<OSVERSIONINFOW*>(&version_info)); + service_pack_major = version_info.wServicePackMajor; + service_pack_minor = version_info.wServicePackMinor; + checked_version = true; + } + + *major = service_pack_major; + *minor = service_pack_minor; +} + +} // namespace win +} // namespace base diff --git a/base/win/windows_version.h b/base/win/windows_version.h new file mode 100644 index 0000000..7e281a6 --- /dev/null +++ b/base/win/windows_version.h @@ -0,0 +1,34 @@ +// Copyright (c) 2010 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. + +#ifndef BASE_WIN_WINDOWS_VERSION_H_ +#define BASE_WIN_WINDOWS_VERSION_H_ +#pragma once + +namespace base { +namespace win { + +// NOTE: Keep these in order so callers can do things like +// "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values, +// though. +enum Version { + VERSION_PRE_2000 = 0, // Not supported + VERSION_2000 = 1, // Not supported + VERSION_XP = 2, + VERSION_SERVER_2003 = 3, + VERSION_VISTA = 4, + VERSION_2008 = 5, + VERSION_WIN7 = 6, +}; + +// Returns the running version of Windows. +Version GetVersion(); + +// Returns the major and minor version of the service pack installed. +void GetServicePackLevel(int* major, int* minor); + +} // namespace win +} // namespace base + +#endif // BASE_WIN_WINDOWS_VERSION_H_ |