]> git.sesse.net Git - casparcg/blob - common/os/windows/system_info.h
2.0. auto-play: Improved and refactored.
[casparcg] / common / os / windows / system_info.h
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\r
6 *    CasparCG is free software: you can redistribute it and/or modify\r
7 *    it under the terms of the GNU General Public License as published by\r
8 *    the Free Software Foundation, either version 3 of the License, or\r
9 *    (at your option) any later version.\r
10 *\r
11 *    CasparCG is distributed in the hope that it will be useful,\r
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 *    GNU General Public License for more details.\r
15 \r
16 *    You should have received a copy of the GNU General Public License\r
17 *    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 */\r
20 #pragma once\r
21 \r
22 #define NOMINMAX\r
23 #define WIN32_LEAN_AND_MEAN\r
24 \r
25 #include <windows.h>\r
26 \r
27 #include <string>\r
28 #include <sstream>\r
29 \r
30 namespace caspar {\r
31         \r
32 static std::wstring get_cpu_info()\r
33 {\r
34         std::wstring cpu_name = L"Unknown CPU";\r
35         HKEY hkey; \r
36         DWORD dwType, dwSize;\r
37         if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)\r
38         {\r
39                 wchar_t p_name_str[1024];\r
40 \r
41                 dwType = REG_SZ;\r
42                 dwSize = sizeof(p_name_str);\r
43 \r
44                 if(RegQueryValueEx(hkey, TEXT("ProcessorNameString"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)             \r
45                         cpu_name = p_name_str;          \r
46                  \r
47                 RegCloseKey(hkey);\r
48         }\r
49 \r
50 \r
51         SYSTEM_INFO sysinfo;\r
52         GetSystemInfo(&sysinfo);\r
53 \r
54         std::wstringstream s;\r
55 \r
56         s << cpu_name << L" Physical Threads: " << sysinfo.dwNumberOfProcessors;\r
57 \r
58         return s.str();\r
59 }\r
60 \r
61 static std::wstring get_system_product_name()\r
62 {\r
63         std::wstring system_product_name = L"Unknown System";\r
64         HKEY hkey; \r
65         DWORD dwType, dwSize;\r
66         if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\BIOS"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)\r
67         {\r
68                 wchar_t p_name_str[1024];\r
69 \r
70                 dwType = REG_SZ;\r
71                 dwSize = sizeof(p_name_str);\r
72 \r
73                 if(RegQueryValueEx(hkey, TEXT("SystemProductName"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)               \r
74                         system_product_name = p_name_str;               \r
75                  \r
76                 RegCloseKey(hkey);\r
77         }\r
78 \r
79         return system_product_name;\r
80 }\r
81 \r
82 \r
83 }