source: vendor/synergy/current/lib/arch/CArchMiscWindows.h

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 4.8 KB
Line 
1/*
2 * synergy -- mouse and keyboard sharing utility
3 * Copyright (C) 2002 Chris Schoeneman
4 *
5 * This package is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * found in the file COPYING that should have accompanied this file.
8 *
9 * This package is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef CARCHMISCWINDOWS_H
16#define CARCHMISCWINDOWS_H
17
18#define WIN32_LEAN_AND_MEAN
19
20#include "common.h"
21#include "stdstring.h"
22#include "stdset.h"
23#include <windows.h>
24
25//! Miscellaneous win32 functions.
26class CArchMiscWindows {
27public:
28 enum EValueType {
29 kUNKNOWN,
30 kNO_VALUE,
31 kUINT,
32 kSTRING,
33 kBINARY
34 };
35 enum EBusyModes {
36 kIDLE = 0x0000,
37 kSYSTEM = 0x0001,
38 kDISPLAY = 0x0002
39 };
40
41 typedef int (*RunFunc)(void);
42
43 //! Initialize
44 static void init();
45
46 //! Test if windows 95, et al.
47 /*!
48 Returns true iff the platform is win95/98/me.
49 */
50 static bool isWindows95Family();
51
52 //! Test if windows 95, et al.
53 /*!
54 Returns true iff the platform is win98 or win2k or higher (i.e.
55 not windows 95 or windows NT).
56 */
57 static bool isWindowsModern();
58
59 //! Set the application icons
60 /*!
61 Set the application icons.
62 */
63 static void setIcons(HICON largeIcon, HICON smallIcon);
64
65 //! Get the application icons
66 /*!
67 Get the application icons.
68 */
69 static void getIcons(HICON& largeIcon, HICON& smallIcon);
70
71 //! Run the daemon
72 /*!
73 Delegates to CArchDaemonWindows.
74 */
75 static int runDaemon(RunFunc runFunc);
76
77 //! Indicate daemon is in main loop
78 /*!
79 Delegates to CArchDaemonWindows.
80 */
81 static void daemonRunning(bool running);
82
83 //! Indicate failure of running daemon
84 /*!
85 Delegates to CArchDaemonWindows.
86 */
87 static void daemonFailed(int result);
88
89 //! Get daemon quit message
90 /*!
91 Delegates to CArchDaemonWindows.
92 */
93 static UINT getDaemonQuitMessage();
94
95 //! Open and return a registry key, closing the parent key
96 static HKEY openKey(HKEY parent, const TCHAR* child);
97
98 //! Open and return a registry key, closing the parent key
99 static HKEY openKey(HKEY parent, const TCHAR* const* keyPath);
100
101 //! Open/create and return a registry key, closing the parent key
102 static HKEY addKey(HKEY parent, const TCHAR* child);
103
104 //! Open/create and return a registry key, closing the parent key
105 static HKEY addKey(HKEY parent, const TCHAR* const* keyPath);
106
107 //! Close a key
108 static void closeKey(HKEY);
109
110 //! Delete a key (which should have no subkeys)
111 static void deleteKey(HKEY parent, const TCHAR* name);
112
113 //! Delete a value
114 static void deleteValue(HKEY parent, const TCHAR* name);
115
116 //! Test if a value exists
117 static bool hasValue(HKEY key, const TCHAR* name);
118
119 //! Get type of value
120 static EValueType typeOfValue(HKEY key, const TCHAR* name);
121
122 //! Set a string value in the registry
123 static void setValue(HKEY key, const TCHAR* name,
124 const std::string& value);
125
126 //! Set a DWORD value in the registry
127 static void setValue(HKEY key, const TCHAR* name, DWORD value);
128
129 //! Set a BINARY value in the registry
130 /*!
131 Sets the \p name value of \p key to \p value.data().
132 */
133 static void setValueBinary(HKEY key, const TCHAR* name,
134 const std::string& value);
135
136 //! Read a string value from the registry
137 static std::string readValueString(HKEY, const TCHAR* name);
138
139 //! Read a DWORD value from the registry
140 static DWORD readValueInt(HKEY, const TCHAR* name);
141
142 //! Read a BINARY value from the registry
143 static std::string readValueBinary(HKEY, const TCHAR* name);
144
145 //! Add a dialog
146 static void addDialog(HWND);
147
148 //! Remove a dialog
149 static void removeDialog(HWND);
150
151 //! Process dialog message
152 /*!
153 Checks if the message is destined for a dialog. If so the message
154 is passed to the dialog and returns true, otherwise returns false.
155 */
156 static bool processDialog(MSG*);
157
158 //! Disable power saving
159 static void addBusyState(DWORD busyModes);
160
161 //! Enable power saving
162 static void removeBusyState(DWORD busyModes);
163
164private:
165 //! Open and return a registry key, closing the parent key
166 static HKEY openKey(HKEY parent, const TCHAR* child, bool create);
167
168 //! Open and return a registry key, closing the parent key
169 static HKEY openKey(HKEY parent, const TCHAR* const* keyPath,
170 bool create);
171
172 //! Read a string value from the registry
173 static std::string readBinaryOrString(HKEY, const TCHAR* name, DWORD type);
174
175 //! Set thread busy state
176 static void setThreadExecutionState(DWORD);
177
178 static DWORD WINAPI dummySetThreadExecutionState(DWORD);
179
180private:
181 typedef std::set<HWND> CDialogs;
182 typedef DWORD (WINAPI *STES_t)(DWORD);
183
184 static CDialogs* s_dialogs;
185 static DWORD s_busyState;
186 static STES_t s_stes;
187 static HICON s_largeIcon;
188 static HICON s_smallIcon;
189};
190
191#endif
Note: See TracBrowser for help on using the repository browser.