1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // WindowsRegistry.cpp: Implementierung der Klasse WindowsRegistry.
23 //
24 //////////////////////////////////////////////////////////////////////
25 
26 #include "windowsregistry.hxx"
27 #include "registrywnt.hxx"
28 #include "registryw9x.hxx"
29 
30 #ifdef _MSC_VER
31 #pragma warning(disable : 4350)
32 #endif
33 
34 //------------------------------
35 //
36 //------------------------------
37 
WindowsRegistry()38 WindowsRegistry::WindowsRegistry()
39 {
40 	OSVERSIONINFOA osverinfo;
41     ZeroMemory(&osverinfo, sizeof(osverinfo));
42     osverinfo.dwOSVersionInfoSize = sizeof(osverinfo);
43     GetVersionExA(&osverinfo);
44 
45     m_IsWinNT = (osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
46 }
47 
48 //------------------------------
49 //
50 //------------------------------
51 
GetClassesRootKey(bool Writeable) const52 RegistryKey WindowsRegistry::GetClassesRootKey(bool Writeable) const
53 {
54 	return GetRegistryKey(HKEY_CLASSES_ROOT, Writeable);
55 }
56 
57 //------------------------------
58 //
59 //------------------------------
60 
GetCurrentUserKey(bool Writeable) const61 RegistryKey WindowsRegistry::GetCurrentUserKey(bool Writeable) const
62 {
63 	return GetRegistryKey(HKEY_CURRENT_USER, Writeable);
64 }
65 
66 //------------------------------
67 //
68 //------------------------------
69 
GetLocalMachineKey(bool Writeable) const70 RegistryKey WindowsRegistry::GetLocalMachineKey(bool Writeable) const
71 {
72 	return GetRegistryKey(HKEY_LOCAL_MACHINE, Writeable);
73 }
74 
75 //------------------------------
76 //
77 //------------------------------
78 
GetUserKey(bool Writeable) const79 RegistryKey WindowsRegistry::GetUserKey(bool Writeable) const
80 {
81 	return GetRegistryKey(HKEY_USERS, Writeable);
82 }
83 
84 //------------------------------
85 //
86 //------------------------------
87 
GetRegistryKey(HKEY RootKey,bool Writeable) const88 RegistryKey WindowsRegistry::GetRegistryKey(HKEY RootKey, bool Writeable) const
89 {
90 	RegistryKey regkey;
91 
92 	if (m_IsWinNT)
93 		regkey = RegistryKey(new RegistryKeyImplWinNT(RootKey));
94 	else
95 		regkey = RegistryKey(new RegistryKeyImplWin9x(RootKey));
96 
97 	regkey->Open(Writeable);
98 
99 	return regkey;
100 }
101