--- old/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp 2015-11-19 18:20:33.689554151 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp 2015-11-19 18:20:33.561554148 +0300 @@ -28,6 +28,13 @@ #include #include #include +#include "awt_Toolkit.h" + +#define NOTIFY_FOR_ALL_SESSIONS 1 +#define NOTIFY_FOR_THIS_SESSION 0 + +typedef BOOL (WINAPI *WTSRegisterSessionNotification)(HWND,DWORD); +static WTSRegisterSessionNotification fn_WTSRegisterSessionNotification; #ifdef __cplusplus extern "C" { @@ -35,6 +42,28 @@ /* * Class: sun_awt_windows_WDesktopPeer + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WDesktopPeer_init + (JNIEnv *, jclass) { + static HMODULE libWtsapi32 = NULL; + if (libWtsapi32 == NULL) { + libWtsapi32 = JDK_LoadSystemLibrary("Wtsapi32.dll"); + if (libWtsapi32) { + fn_WTSRegisterSessionNotification = (WTSRegisterSessionNotification) + GetProcAddress(libWtsapi32, "WTSRegisterSessionNotification"); + if (fn_WTSRegisterSessionNotification) { + HWND hwnd = AwtToolkit::GetInstance().GetHWnd(); + //used for UserSessionListener + fn_WTSRegisterSessionNotification(hwnd, NOTIFY_FOR_THIS_SESSION); + } + } + } +} + +/* + * Class: sun_awt_windows_WDesktopPeer * Method: ShellExecute * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; */