1*32b1fd08SAndrew Rist /**************************************************************
2*32b1fd08SAndrew Rist  *
3*32b1fd08SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*32b1fd08SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*32b1fd08SAndrew Rist  * distributed with this work for additional information
6*32b1fd08SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*32b1fd08SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*32b1fd08SAndrew Rist  * "License"); you may not use this file except in compliance
9*32b1fd08SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*32b1fd08SAndrew Rist  *
11*32b1fd08SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*32b1fd08SAndrew Rist  *
13*32b1fd08SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*32b1fd08SAndrew Rist  * software distributed under the License is distributed on an
15*32b1fd08SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*32b1fd08SAndrew Rist  * KIND, either express or implied.  See the License for the
17*32b1fd08SAndrew Rist  * specific language governing permissions and limitations
18*32b1fd08SAndrew Rist  * under the License.
19*32b1fd08SAndrew Rist  *
20*32b1fd08SAndrew Rist  *************************************************************/
21*32b1fd08SAndrew Rist 
22cdf0e10cSrcweir // RegistryException.cpp: Implementierung der Klasse RegistryException.
23cdf0e10cSrcweir //
24cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "registryexception.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifdef _MSC_VER
29cdf0e10cSrcweir #pragma warning(push, 1) /* disable warnings within system headers */
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <windows.h>
32cdf0e10cSrcweir #ifdef _MSC_VER
33cdf0e10cSrcweir #pragma warning(pop)
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
37cdf0e10cSrcweir // Konstruktion/Destruktion
38cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
39cdf0e10cSrcweir 
RegistryException(long ErrorCode)40cdf0e10cSrcweir RegistryException::RegistryException(long ErrorCode) :
41cdf0e10cSrcweir 	m_ErrorCode(ErrorCode),
42cdf0e10cSrcweir 	m_ErrorMsg(0)
43cdf0e10cSrcweir {
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /**
47cdf0e10cSrcweir */
~RegistryException()48cdf0e10cSrcweir RegistryException::~RegistryException() throw()
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 	if (m_ErrorMsg)
51cdf0e10cSrcweir 		LocalFree(m_ErrorMsg);
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /**
55cdf0e10cSrcweir */
what() const56cdf0e10cSrcweir const char* RegistryException::what() const throw()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	FormatMessage(
59cdf0e10cSrcweir 		FORMAT_MESSAGE_ALLOCATE_BUFFER |
60cdf0e10cSrcweir 		FORMAT_MESSAGE_FROM_SYSTEM |
61cdf0e10cSrcweir 		FORMAT_MESSAGE_IGNORE_INSERTS,
62cdf0e10cSrcweir 		NULL,
63cdf0e10cSrcweir 		m_ErrorCode,
64cdf0e10cSrcweir 		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
65cdf0e10cSrcweir 		(LPTSTR) &m_ErrorMsg,
66cdf0e10cSrcweir 		0,
67cdf0e10cSrcweir 		NULL);
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	return reinterpret_cast<char*>(m_ErrorMsg);
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir /**
73cdf0e10cSrcweir */
GetErrorCode() const74cdf0e10cSrcweir long RegistryException::GetErrorCode() const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	return m_ErrorCode;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir //#######################################
80cdf0e10cSrcweir // Thrown when a Registry key is accessed
81cdf0e10cSrcweir // that is closed
82cdf0e10cSrcweir //#######################################
83cdf0e10cSrcweir 
RegistryIOException(long ErrorCode)84cdf0e10cSrcweir RegistryIOException::RegistryIOException(long ErrorCode) :
85cdf0e10cSrcweir 	RegistryException(ErrorCode)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir };
88cdf0e10cSrcweir 
89cdf0e10cSrcweir //#######################################
90cdf0e10cSrcweir //
91cdf0e10cSrcweir //#######################################
92cdf0e10cSrcweir 
RegistryNoWriteAccessException(long ErrorCode)93cdf0e10cSrcweir RegistryNoWriteAccessException::RegistryNoWriteAccessException(long ErrorCode) :
94cdf0e10cSrcweir 	RegistryException(ErrorCode)
95cdf0e10cSrcweir {
96cdf0e10cSrcweir };
97cdf0e10cSrcweir 
98cdf0e10cSrcweir //#######################################
99cdf0e10cSrcweir //
100cdf0e10cSrcweir //#######################################
101cdf0e10cSrcweir 
RegistryAccessDeniedException(long ErrorCode)102cdf0e10cSrcweir RegistryAccessDeniedException::RegistryAccessDeniedException(long ErrorCode) :
103cdf0e10cSrcweir 	RegistryException(ErrorCode)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir };
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //#######################################
108cdf0e10cSrcweir //
109cdf0e10cSrcweir //#######################################
110cdf0e10cSrcweir 
RegistryValueNotFoundException(long ErrorCode)111cdf0e10cSrcweir RegistryValueNotFoundException::RegistryValueNotFoundException(long ErrorCode) :
112cdf0e10cSrcweir 	RegistryException(ErrorCode)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir //#######################################
117cdf0e10cSrcweir //
118cdf0e10cSrcweir //#######################################
119cdf0e10cSrcweir 
RegistryKeyNotFoundException(long ErrorCode)120cdf0e10cSrcweir RegistryKeyNotFoundException::RegistryKeyNotFoundException(long ErrorCode) :
121cdf0e10cSrcweir 	RegistryException(ErrorCode)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir };
124cdf0e10cSrcweir 
125cdf0e10cSrcweir //#######################################
126cdf0e10cSrcweir //
127cdf0e10cSrcweir //#######################################
128cdf0e10cSrcweir 
RegistryInvalidOperationException(long ErrorCode)129cdf0e10cSrcweir RegistryInvalidOperationException::RegistryInvalidOperationException(long ErrorCode) :
130cdf0e10cSrcweir 	RegistryException(ErrorCode)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir };
133