2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
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.
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.
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/>.
19 * Author: Robert Nagy, ronag89@gmail.com
22 #include "../../stdafx.h"
24 #include "../system_info.h"
25 #include "current_version.h"
34 std::wstring cpu_info()
36 std::wstring cpu_name = L"Unknown CPU";
39 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
41 wchar_t p_name_str[1024];
44 dwSize = sizeof(p_name_str);
46 if(RegQueryValueEx(hkey, TEXT("ProcessorNameString"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)
47 cpu_name = p_name_str;
54 GetSystemInfo(&sysinfo);
58 s << cpu_name << L" Physical Threads: " << sysinfo.dwNumberOfProcessors;
63 std::wstring system_product_name()
65 std::wstring system_product_name = L"Unknown System";
68 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\BIOS"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
70 wchar_t p_name_str[1024];
73 dwSize = sizeof(p_name_str);
75 if(RegQueryValueEx(hkey, TEXT("SystemProductName"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)
76 system_product_name = p_name_str;
81 return system_product_name;
84 std::wstring os_description()
86 return win_product_name() + L" " + win_sp_version();
90 /*static std::map<std::wstring, std::wstring> enumerate_fonts()
92 std::map<std::wstring, std::wstring> result;
93 const DWORD max_str_length = 32766;
96 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
101 DWORD name_length = max_str_length;
102 wchar_t name[max_str_length];
104 DWORD value_length = max_str_length;
105 wchar_t value[max_str_length];
107 long code = RegEnumValueW(hkey, index, name, &name_length, NULL, NULL, (PBYTE)value, &value_length);
108 if(code == ERROR_SUCCESS)
110 std::wstring name_str(name);
111 name_str = name_str.substr(0, name_str.find_last_of(L' ')); //the font names are formated like this: "AGaramondPro-Italic (OpenType)". We need to strip away the '(OpenType)'-part
112 result.insert(std::pair<std::wstring, std::wstring>(name_str, std::wstring(value)));
114 else if(code == ERROR_NO_MORE_ITEMS)
118 //if(RegQueryValueEx(hkey, TEXT("SystemProductName"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)
119 // system_product_name = p_name_str;