CArchMiscWindows.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #ifndef CARCHMISCWINDOWS_H
00016 #define CARCHMISCWINDOWS_H
00017 
00018 #define WIN32_LEAN_AND_MEAN
00019 
00020 #include "common.h"
00021 #include "stdstring.h"
00022 #include "stdset.h"
00023 #include <windows.h>
00024 
00026 class CArchMiscWindows {
00027 public:
00028     enum EValueType {
00029         kUNKNOWN,
00030         kNO_VALUE,
00031         kUINT,
00032         kSTRING,
00033         kBINARY
00034     };
00035     enum EBusyModes {
00036         kIDLE   = 0x0000,
00037         kSYSTEM  = 0x0001,
00038         kDISPLAY = 0x0002
00039     };
00040 
00041     typedef int         (*RunFunc)(void);
00042 
00044     static void         init();
00045 
00047 
00050     static bool         isWindows95Family();
00051 
00053 
00057     static bool         isWindowsModern();
00058 
00060 
00063     static void         setIcons(HICON largeIcon, HICON smallIcon);
00064 
00066 
00069     static void         getIcons(HICON& largeIcon, HICON& smallIcon);
00070 
00072 
00075     static int          runDaemon(RunFunc runFunc);
00076 
00078 
00081     static void         daemonRunning(bool running);
00082 
00084 
00087     static void         daemonFailed(int result);
00088 
00090 
00093     static UINT         getDaemonQuitMessage();
00094 
00096     static HKEY         openKey(HKEY parent, const TCHAR* child);
00097 
00099     static HKEY         openKey(HKEY parent, const TCHAR* const* keyPath);
00100 
00102     static HKEY         addKey(HKEY parent, const TCHAR* child);
00103 
00105     static HKEY         addKey(HKEY parent, const TCHAR* const* keyPath);
00106 
00108     static void         closeKey(HKEY);
00109 
00111     static void         deleteKey(HKEY parent, const TCHAR* name);
00112 
00114     static void         deleteValue(HKEY parent, const TCHAR* name);
00115 
00117     static bool         hasValue(HKEY key, const TCHAR* name);
00118 
00120     static EValueType   typeOfValue(HKEY key, const TCHAR* name);
00121 
00123     static void         setValue(HKEY key, const TCHAR* name,
00124                             const std::string& value);
00125 
00127     static void         setValue(HKEY key, const TCHAR* name, DWORD value);
00128 
00130 
00133     static void         setValueBinary(HKEY key, const TCHAR* name,
00134                             const std::string& value);
00135 
00137     static std::string  readValueString(HKEY, const TCHAR* name);
00138 
00140     static DWORD        readValueInt(HKEY, const TCHAR* name);
00141 
00143     static std::string  readValueBinary(HKEY, const TCHAR* name);
00144 
00146     static void         addDialog(HWND);
00147 
00149     static void         removeDialog(HWND);
00150 
00152 
00156     static bool         processDialog(MSG*);
00157 
00159     static void         addBusyState(DWORD busyModes);
00160 
00162     static void         removeBusyState(DWORD busyModes);
00163 
00165     static void         wakeupDisplay();
00166 
00167 private:
00169     static HKEY         openKey(HKEY parent, const TCHAR* child, bool create);
00170 
00172     static HKEY         openKey(HKEY parent, const TCHAR* const* keyPath,
00173                             bool create);
00174 
00176     static std::string  readBinaryOrString(HKEY, const TCHAR* name, DWORD type);
00177 
00179     static void         setThreadExecutionState(DWORD);
00180 
00181     static DWORD WINAPI dummySetThreadExecutionState(DWORD);
00182 
00183 private:
00184     typedef std::set<HWND> CDialogs;
00185     typedef DWORD (WINAPI *STES_t)(DWORD);
00186 
00187     static CDialogs*    s_dialogs;
00188     static DWORD        s_busyState;
00189     static STES_t       s_stes;
00190     static HICON        s_largeIcon;
00191     static HICON        s_smallIcon;
00192 };
00193 
00194 #endif

Generated on Fri Nov 6 00:18:44 2009 for synergy-plus by  doxygen 1.4.7