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