2010-03-20 19:40:30 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 spx
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-03-20 19:40:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RAINMETER_SYSTEM_H__
|
|
|
|
#define __RAINMETER_SYSTEM_H__
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <vector>
|
|
|
|
|
2010-09-11 19:39:45 +00:00
|
|
|
enum OSPLATFORM
|
|
|
|
{
|
|
|
|
OSPLATFORM_UNKNOWN = 0,
|
|
|
|
OSPLATFORM_XP,
|
|
|
|
OSPLATFORM_VISTA,
|
|
|
|
OSPLATFORM_7
|
|
|
|
};
|
|
|
|
|
2012-06-01 13:13:01 +00:00
|
|
|
struct MonitorInfo
|
2010-03-20 19:40:30 +00:00
|
|
|
{
|
|
|
|
bool active;
|
|
|
|
HMONITOR handle;
|
|
|
|
RECT screen;
|
|
|
|
RECT work;
|
2012-05-20 17:57:12 +00:00
|
|
|
std::wstring deviceName; // Device name (E.g. "\\.\DISPLAY1")
|
|
|
|
std::wstring monitorName; // Monitor name (E.g. "Generic Non-PnP Monitor")
|
2010-03-20 19:40:30 +00:00
|
|
|
};
|
|
|
|
|
2012-06-01 13:13:01 +00:00
|
|
|
struct MultiMonitorInfo
|
2010-03-20 19:40:30 +00:00
|
|
|
{
|
2012-05-20 17:57:12 +00:00
|
|
|
bool useEnumDisplayDevices; // If true, use EnumDisplayDevices function to obtain the multi-monitor information
|
|
|
|
bool useEnumDisplayMonitors; // If true, use EnumDisplayMonitors function to obtain the multi-monitor information
|
2010-03-20 19:40:30 +00:00
|
|
|
|
2012-05-20 17:57:12 +00:00
|
|
|
int vsT, vsL, vsH, vsW; // Coordinates of the top-left corner (vsT,vsL) and size (vsH,vsW) of the virtual screen
|
|
|
|
int primary; // Index of the primary monitor
|
2012-06-01 13:13:01 +00:00
|
|
|
std::vector<MonitorInfo> monitors;
|
2010-03-20 19:40:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CSystem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void Initialize(HINSTANCE instance);
|
|
|
|
static void Finalize();
|
|
|
|
|
2012-06-01 13:13:01 +00:00
|
|
|
static const MultiMonitorInfo& GetMultiMonitorInfo() { return c_Monitors; }
|
2010-03-20 19:40:30 +00:00
|
|
|
static size_t GetMonitorCount();
|
|
|
|
|
|
|
|
static bool GetShowDesktop() { return c_ShowDesktop; }
|
|
|
|
|
2011-11-10 11:50:47 +00:00
|
|
|
static HWND GetWindow() { return c_Window; }
|
|
|
|
static HWND GetBackmostTopWindow();
|
|
|
|
|
2010-03-29 21:50:05 +00:00
|
|
|
static HWND GetHelperWindow() { return c_HelperWindow; }
|
2011-08-13 10:03:16 +00:00
|
|
|
static void PrepareHelperWindow(HWND WorkerW = GetWorkerW());
|
2010-03-20 19:40:30 +00:00
|
|
|
|
2011-11-10 11:50:47 +00:00
|
|
|
static OSPLATFORM GetOSPlatform() { return c_Platform; }
|
2011-06-05 12:32:18 +00:00
|
|
|
static ULONGLONG GetTickCount64();
|
2012-11-24 11:22:33 +00:00
|
|
|
static POINT GetCursorPosition();
|
2010-09-11 19:39:45 +00:00
|
|
|
|
2011-11-05 09:01:06 +00:00
|
|
|
static bool IsPathSeparator(WCHAR ch) { return (ch == L'\\' || ch == L'/'); }
|
|
|
|
static bool IsUNCPath(const std::wstring& path) { return (path.length() >= 2 && IsPathSeparator(path[0]) && IsPathSeparator(path[1])); }
|
|
|
|
static bool IsAbsolutePath(const std::wstring& path) { return (path.find(L":\\") != std::wstring::npos || path.find(L":/") != std::wstring::npos || IsUNCPath(path)); }
|
|
|
|
|
2011-11-08 19:02:31 +00:00
|
|
|
static bool IsFileWritable(LPCWSTR file);
|
|
|
|
|
2012-08-12 14:46:23 +00:00
|
|
|
static HMODULE RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError = NULL);
|
2011-05-23 20:21:19 +00:00
|
|
|
static void ResetWorkingDirectory();
|
2011-05-22 16:02:43 +00:00
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
static void SetClipboardText(const std::wstring& text);
|
2012-02-04 15:54:30 +00:00
|
|
|
static void SetWallpaper(const std::wstring& wallpaper, const std::wstring& style);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-05-30 05:10:12 +00:00
|
|
|
static bool CopyFiles(std::wstring from, std::wstring to, bool bMove = false);
|
2010-08-03 15:10:42 +00:00
|
|
|
static bool RemoveFile(const std::wstring& file);
|
2012-06-10 10:14:49 +00:00
|
|
|
static bool RemoveFolder(std::wstring folder);
|
2010-08-03 15:10:42 +00:00
|
|
|
|
2011-11-10 13:44:19 +00:00
|
|
|
static void UpdateIniFileMappingList();
|
|
|
|
static std::wstring GetTemporaryFile(const std::wstring& iniFile);
|
2010-08-03 15:10:42 +00:00
|
|
|
|
2010-03-20 19:40:30 +00:00
|
|
|
private:
|
2010-03-29 21:50:05 +00:00
|
|
|
static void CALLBACK MyWinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime);
|
2010-03-20 19:40:30 +00:00
|
|
|
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
|
|
|
static void SetMultiMonitorInfo();
|
|
|
|
static void ClearMultiMonitorInfo() { c_Monitors.monitors.clear(); }
|
|
|
|
static void UpdateWorkareaInfo();
|
|
|
|
|
2011-11-10 12:09:50 +00:00
|
|
|
static void SetOSPlatform();
|
|
|
|
|
2010-03-29 21:50:05 +00:00
|
|
|
static HWND GetDefaultShellWindow();
|
2011-08-13 10:03:16 +00:00
|
|
|
static HWND GetWorkerW();
|
2010-03-20 19:40:30 +00:00
|
|
|
static void ChangeZPosInOrder();
|
|
|
|
|
2011-06-23 13:29:51 +00:00
|
|
|
static bool CheckDesktopState(HWND WorkerW);
|
2010-03-29 21:50:05 +00:00
|
|
|
static bool BelongToSameProcess(HWND hwndA, HWND hwndB);
|
|
|
|
|
2010-03-20 19:40:30 +00:00
|
|
|
static HWND c_Window;
|
2010-03-29 21:50:05 +00:00
|
|
|
static HWND c_HelperWindow;
|
|
|
|
|
|
|
|
static HWINEVENTHOOK c_WinEventHook;
|
2010-03-20 19:40:30 +00:00
|
|
|
|
2012-06-01 13:13:01 +00:00
|
|
|
static MultiMonitorInfo c_Monitors;
|
2010-03-20 19:40:30 +00:00
|
|
|
|
|
|
|
static bool c_ShowDesktop;
|
2010-09-11 19:39:45 +00:00
|
|
|
|
|
|
|
static OSPLATFORM c_Platform;
|
2011-05-22 16:02:43 +00:00
|
|
|
|
|
|
|
static std::wstring c_WorkingDirectory;
|
2011-11-10 13:44:19 +00:00
|
|
|
|
|
|
|
static std::vector<std::wstring> c_IniFileMappings;
|
2010-03-20 19:40:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|