]> git.sesse.net Git - casparcg/blob - common/os/windows/current_version.h
14d3d6d1d62594ad6473721141eb924d76ab531f
[casparcg] / common / os / windows / current_version.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 #define NOMINMAX
25 #define WIN32_LEAN_AND_MEAN
26
27 #include "windows.h"
28
29 #include <string>
30
31 namespace caspar {
32
33 static std::wstring win_product_name()
34 {
35         std::wstring result = L"Unknown Windows Product Name.";
36         HKEY hkey; 
37         DWORD dwType, dwSize;
38         if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), 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("ProductName"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)             
46                         result = p_name_str;            
47                  
48                 RegCloseKey(hkey);
49         }
50         return result;
51 }
52
53 static std::wstring win_sp_version()
54 {
55         std::wstring result =  L"";
56         HKEY hkey; 
57         DWORD dwType, dwSize;
58         if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
59         {
60                 wchar_t csd_ver_str[1024];
61
62                 dwType = REG_SZ;
63                 dwSize = sizeof(csd_ver_str);
64
65                 if(RegQueryValueEx(hkey, TEXT("CSDVersion"), NULL, &dwType, (PBYTE)&csd_ver_str, &dwSize) == ERROR_SUCCESS)             
66                         result = csd_ver_str;
67                  
68                 RegCloseKey(hkey);
69         }
70         return result;
71 }
72
73 }