]> git.sesse.net Git - casparcg/blob - common/os/windows/system_info.cpp
[ffmpeg] Remove redundant av_frame_alloc()/av_frame_free() RAII pairs all over the...
[casparcg] / common / os / windows / system_info.cpp
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 #include "../../stdafx.h"
23
24 #include "../system_info.h"
25
26 #include "windows.h"
27
28 #include <sstream>
29 #include <map>
30
31 namespace caspar {
32         
33 std::wstring cpu_info()
34 {
35         std::wstring cpu_name = L"Unknown CPU";
36         HKEY hkey; 
37         DWORD dwType, dwSize;
38         if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
39         {
40                 wchar_t p_name_str[1024];
41
42                 dwType = REG_SZ;
43                 dwSize = sizeof(p_name_str);
44
45                 if(RegQueryValueEx(hkey, TEXT("ProcessorNameString"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)             
46                         cpu_name = p_name_str;          
47                  
48                 RegCloseKey(hkey);
49         }
50
51
52         SYSTEM_INFO sysinfo;
53         GetSystemInfo(&sysinfo);
54
55         std::wstringstream s;
56
57         s << cpu_name << L" Physical Threads: " << sysinfo.dwNumberOfProcessors;
58
59         return s.str();
60 }
61
62 std::wstring system_product_name()
63 {
64         std::wstring system_product_name = L"Unknown System";
65         HKEY hkey; 
66         DWORD dwType, dwSize;
67         if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\BIOS"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
68         {
69                 wchar_t p_name_str[1024];
70
71                 dwType = REG_SZ;
72                 dwSize = sizeof(p_name_str);
73
74                 if(RegQueryValueEx(hkey, TEXT("SystemProductName"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)               
75                         system_product_name = p_name_str;               
76                  
77                 RegCloseKey(hkey);
78         }
79
80         return system_product_name;
81 }
82
83 std::wstring win_product_name()
84 {
85         std::wstring result = L"Unknown Windows Product Name.";
86         HKEY hkey;
87         DWORD dwType, dwSize;
88         if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
89         {
90                 wchar_t p_name_str[1024];
91
92                 dwType = REG_SZ;
93                 dwSize = sizeof(p_name_str);
94
95                 if (RegQueryValueEx(hkey, TEXT("ProductName"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)
96                         result = p_name_str;
97
98                 RegCloseKey(hkey);
99         }
100         return result;
101 }
102
103 std::wstring win_sp_version()
104 {
105         std::wstring result = L"";
106         HKEY hkey;
107         DWORD dwType, dwSize;
108         if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
109         {
110                 wchar_t csd_ver_str[1024];
111
112                 dwType = REG_SZ;
113                 dwSize = sizeof(csd_ver_str);
114
115                 if (RegQueryValueEx(hkey, TEXT("CSDVersion"), NULL, &dwType, (PBYTE)&csd_ver_str, &dwSize) == ERROR_SUCCESS)
116                         result = csd_ver_str;
117
118                 RegCloseKey(hkey);
119         }
120         return result;
121 }
122
123 std::wstring os_description()
124 {
125         return win_product_name() + L" " + win_sp_version();
126 }
127
128 }