From fdbc3639a50f40879f390f17ce7aafd5a579a7ab Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sat, 21 Sep 2013 17:37:33 +0000 Subject: Core cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@6165 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdidle/commonheaders.h | 14 +--------- src/core/stdidle/idle.cpp | 56 +++++++++---------------------------- src/core/stdidle/main.cpp | 12 -------- src/core/stdidle/stdidle_10.vcxproj | 13 ++++----- src/core/stdidle/stdidle_11.vcxproj | 13 ++++----- 5 files changed, 24 insertions(+), 84 deletions(-) (limited to 'src/core/stdidle') diff --git a/src/core/stdidle/commonheaders.h b/src/core/stdidle/commonheaders.h index 7455afd2a0..3ee34d7e8a 100644 --- a/src/core/stdidle/commonheaders.h +++ b/src/core/stdidle/commonheaders.h @@ -28,9 +28,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include +#include #include #include @@ -75,15 +75,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../stdplug.h" extern HINSTANCE hInst; - -typedef HDESK (WINAPI* pfnOpenInputDesktop)(DWORD, BOOL, DWORD); -extern pfnOpenInputDesktop openInputDesktop; - -typedef HDESK (WINAPI* pfnCloseDesktop)(HDESK); -extern pfnCloseDesktop closeDesktop; - -typedef HMONITOR(WINAPI *pfnMyMonitorFromWindow) (HWND, DWORD); -extern pfnMyMonitorFromWindow MyMonitorFromWindow; - -typedef BOOL(WINAPI *pfnMyGetMonitorInfo) (HMONITOR, LPMONITORINFO); -extern pfnMyGetMonitorInfo MyGetMonitorInfo; diff --git a/src/core/stdidle/idle.cpp b/src/core/stdidle/idle.cpp index a66f05d93e..4881c0f592 100644 --- a/src/core/stdidle/idle.cpp +++ b/src/core/stdidle/idle.cpp @@ -105,42 +105,21 @@ typedef enum _WTS_INFO_CLASS { #endif -VOID (WINAPI *_WTSFreeMemory)(PVOID); -BOOL (WINAPI *_WTSQuerySessionInformation)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*); - -BOOL bIsWTSApiPresent = FALSE; - static BOOL bModuleInitialized = FALSE; -BOOL InitWTSAPI() -{ - HMODULE hDll = LoadLibraryA("wtsapi32.dll"); - if (hDll) { - _WTSFreeMemory = (VOID (WINAPI *)(PVOID))GetProcAddress(hDll, "WTSFreeMemory"); - _WTSQuerySessionInformation = (BOOL (WINAPI *)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*))GetProcAddress(hDll, "WTSQuerySessionInformationW"); - - if (_WTSFreeMemory && _WTSQuerySessionInformation) return 1; - } - return 0; -} - BOOL IsTerminalDisconnected() { PVOID pBuffer = NULL; DWORD pBytesReturned = 0; BOOL result = FALSE; - if ( !bIsWTSApiPresent) - return FALSE; - - if (_WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState, &pBuffer, &pBytesReturned)) { + if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState, (LPTSTR *)&pBuffer, &pBytesReturned)) { if (*(PDWORD)pBuffer == WTSDisconnected) result = TRUE; } - else bIsWTSApiPresent = FALSE; if (pBuffer) - _WTSFreeMemory(pBuffer); + WTSFreeMemory(pBuffer); return result; } @@ -233,13 +212,11 @@ static bool IsWorkstationLocked (void) { bool rc = false; - if (openInputDesktop != NULL) { - HDESK hDesk = openInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); - if (hDesk == NULL) - rc = true; - else if (closeDesktop != NULL) - closeDesktop(hDesk); - } + HDESK hDesk = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); + if (hDesk == NULL) + rc = true; + else + CloseDesktop(hDesk); return rc; } @@ -257,13 +234,11 @@ bool IsFullScreen(void) rcScreen.right = GetSystemMetrics(SM_CXSCREEN); rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN); - if (MyMonitorFromWindow) { - HMONITOR hMon = MyMonitorFromWindow(pcli->hwndContactList, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi; - mi.cbSize = sizeof(mi); - if (MyGetMonitorInfo(hMon, &mi)) - rcScreen = mi.rcMonitor; - } + HMONITOR hMon = MonitorFromWindow(pcli->hwndContactList, MONITOR_DEFAULTTONEAREST); + MONITORINFO mi; + mi.cbSize = sizeof(mi); + if (GetMonitorInfo(hMon, &mi)) + rcScreen = mi.rcMonitor; HWND hWndDesktop = GetDesktopWindow(); HWND hWndShell = GetShellWindow(); @@ -358,10 +333,7 @@ static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L CheckDlgButton(hwndDlg, IDC_LOCKED, db_get_b(NULL, IDLEMOD, IDL_IDLEONLOCK, 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_IDLEPRIVATE, db_get_b(NULL, IDLEMOD, IDL_IDLEPRIVATE, 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_IDLESTATUSLOCK, db_get_b(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, 0) ? BST_CHECKED : BST_UNCHECKED); - if ( !bIsWTSApiPresent) - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLETERMINAL), FALSE); - else - CheckDlgButton(hwndDlg, IDC_IDLETERMINAL, db_get_b(NULL, IDLEMOD, IDL_IDLEONTSDC, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IDLETERMINAL, db_get_b(NULL, IDLEMOD, IDL_IDLEONTSDC, 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_IDLESOUNDSOFF, db_get_b(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_IDLE1STTIME), 0); SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETRANGE32, 1, 60); @@ -500,8 +472,6 @@ int LoadIdleModule(void) { bModuleInitialized = TRUE; - bIsWTSApiPresent = InitWTSAPI(); - MyGetLastInputInfo = (BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo"); hIdleEvent = CreateHookableEvent(ME_IDLE_CHANGED); IdleObject_Create(&gIdleObject); CreateServiceFunction(MS_IDLE_GETIDLEINFO, IdleGetInfo); diff --git a/src/core/stdidle/main.cpp b/src/core/stdidle/main.cpp index 50a9b58e6f..36dd64b1ad 100644 --- a/src/core/stdidle/main.cpp +++ b/src/core/stdidle/main.cpp @@ -29,11 +29,6 @@ TIME_API tmi; HINSTANCE hInst; int hLangpack; -pfnMyMonitorFromWindow MyMonitorFromWindow; -pfnMyGetMonitorInfo MyGetMonitorInfo; -pfnOpenInputDesktop openInputDesktop; -pfnCloseDesktop closeDesktop; - PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -65,13 +60,6 @@ extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); mir_getTMI(&tmi); - - HINSTANCE hUser32 = GetModuleHandleA("user32"); - openInputDesktop = (pfnOpenInputDesktop)GetProcAddress (hUser32, "OpenInputDesktop"); - closeDesktop = (pfnCloseDesktop)GetProcAddress (hUser32, "CloseDesktop"); - - MyMonitorFromWindow = (pfnMyMonitorFromWindow)GetProcAddress(hUser32, "MonitorFromWindow"); - MyGetMonitorInfo = (pfnMyGetMonitorInfo)GetProcAddress(hUser32, "GetMonitorInfoW"); mir_getCLI(); LoadIdleModule(); diff --git a/src/core/stdidle/stdidle_10.vcxproj b/src/core/stdidle/stdidle_10.vcxproj index f73f82cffb..01ed78aea8 100644 --- a/src/core/stdidle/stdidle_10.vcxproj +++ b/src/core/stdidle/stdidle_10.vcxproj @@ -91,7 +91,7 @@ ..\..\..\include\msapi;..\..\..\include - miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + miranda32.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies) true true true @@ -125,7 +125,7 @@ ..\..\..\include\msapi;..\..\..\include - miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + miranda32.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies) true 0x3ae00000 false @@ -156,7 +156,7 @@ ..\..\..\include\msapi;..\..\..\include - miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + miranda64.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies) true true true @@ -189,7 +189,7 @@ ..\..\..\include\msapi;..\..\..\include - miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + miranda64.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies) true 0x3ae00000 false @@ -200,10 +200,7 @@ - Create - Create - Create - Create + Create diff --git a/src/core/stdidle/stdidle_11.vcxproj b/src/core/stdidle/stdidle_11.vcxproj index 5e3fa1214d..50e2ce737e 100644 --- a/src/core/stdidle/stdidle_11.vcxproj +++ b/src/core/stdidle/stdidle_11.vcxproj @@ -95,7 +95,7 @@ ..\..\..\include\msapi;..\..\..\include - miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + miranda32.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies) true true true @@ -128,7 +128,7 @@ ..\..\..\include\msapi;..\..\..\include - miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + miranda32.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies) true 0x3ae00000 false @@ -160,7 +160,7 @@ ..\..\..\include\msapi;..\..\..\include - miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + miranda64.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies) true true true @@ -192,7 +192,7 @@ ..\..\..\include\msapi;..\..\..\include - miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + miranda64.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies) true 0x3ae00000 false @@ -203,10 +203,7 @@ - Create - Create - Create - Create + Create -- cgit v1.2.3