SysHelper.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright: JessMA Open Source (ldcsaa@gmail.com)
  3. *
  4. * Version : 2.3.15
  5. * Author : Bruce Liang
  6. * Website : http://www.jessma.org
  7. * Project : https://github.com/ldcsaa
  8. * Blog : http://www.cnblogs.com/ldcsaa
  9. * Wiki : http://www.oschina.net/p/hp-socket
  10. * QQ Group : 75375912
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the "License");
  13. * you may not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * http://www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an "AS IS" BASIS,
  20. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #include "stdafx.h"
  25. #include "SysHelper.h"
  26. #include "GeneralHelper.h"
  27. VOID SysGetSystemInfo(LPSYSTEM_INFO pInfo)
  28. {
  29. ASSERT(pInfo != nullptr);
  30. ::GetNativeSystemInfo(pInfo);
  31. }
  32. DWORD SysGetNumberOfProcessors()
  33. {
  34. SYSTEM_INFO si;
  35. SysGetSystemInfo(&si);
  36. return si.dwNumberOfProcessors;
  37. }
  38. DWORD SysGetPageSize()
  39. {
  40. SYSTEM_INFO si;
  41. SysGetSystemInfo(&si);
  42. return si.dwPageSize;
  43. }
  44. #if _MSC_VER < 1800
  45. BOOL SysGetOSVersionInfo(LPOSVERSIONINFO pInfo, BOOL bInfoEx)
  46. {
  47. ASSERT(pInfo != nullptr);
  48. pInfo->dwOSVersionInfoSize = bInfoEx ? sizeof(LPOSVERSIONINFOEX) : sizeof(LPOSVERSIONINFO);
  49. return ::GetVersionEx(pInfo);
  50. }
  51. DWORD SysGetOSVersion()
  52. {
  53. OSVERSIONINFO vi;
  54. DWORD dwOSVersion = 0;
  55. if(SysGetOSVersionInfo(&vi))
  56. dwOSVersion = (vi.dwMajorVersion << 16) + vi.dwMinorVersion;
  57. return dwOSVersion;
  58. }
  59. #endif