< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Desktop.cpp

Print this page




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include "jni_util.h"
  27 #include "awt.h"
  28 #include <jni.h>
  29 #include <shellapi.h>
  30 #include <float.h>







  31 
  32 #ifdef __cplusplus
  33 extern "C" {
  34 #endif
  35 






















  36 /*
  37  * Class:     sun_awt_windows_WDesktopPeer
  38  * Method:    ShellExecute
  39  * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
  40  */
  41 JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute
  42   (JNIEnv *env, jclass cls, jstring fileOrUri_j, jstring verb_j)
  43 {
  44     LPCWSTR fileOrUri_c = JNU_GetStringPlatformChars(env, fileOrUri_j, JNI_FALSE);
  45     CHECK_NULL_RETURN(fileOrUri_c, NULL);
  46     LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, JNI_FALSE);
  47     if (verb_c == NULL) {
  48         JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
  49         return NULL;
  50     }
  51 
  52     // 6457572: ShellExecute possibly changes FPU control word - saving it here
  53     unsigned oldcontrol87 = _control87(0, 0);
  54     HINSTANCE retval = ::ShellExecute(NULL, verb_c, fileOrUri_c, NULL, NULL, SW_SHOWNORMAL);
  55     DWORD error = ::GetLastError();




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include "jni_util.h"
  27 #include "awt.h"
  28 #include <jni.h>
  29 #include <shellapi.h>
  30 #include <float.h>
  31 #include "awt_Toolkit.h"
  32 
  33 #define NOTIFY_FOR_ALL_SESSIONS 1
  34 #define NOTIFY_FOR_THIS_SESSION 0
  35 
  36 typedef BOOL (WINAPI *WTSRegisterSessionNotification)(HWND,DWORD);
  37 static WTSRegisterSessionNotification fn_WTSRegisterSessionNotification;
  38 
  39 #ifdef __cplusplus
  40 extern "C" {
  41 #endif
  42 
  43 /*
  44  * Class:     sun_awt_windows_WDesktopPeer
  45  * Method:    init
  46  * Signature: ()V
  47  */
  48 JNIEXPORT void JNICALL Java_sun_awt_windows_WDesktopPeer_init
  49   (JNIEnv *, jclass) {
  50     static HMODULE libWtsapi32 = NULL;
  51     if (libWtsapi32 == NULL) {
  52         libWtsapi32 = JDK_LoadSystemLibrary("Wtsapi32.dll");
  53         if (libWtsapi32) {
  54             fn_WTSRegisterSessionNotification = (WTSRegisterSessionNotification)
  55                     GetProcAddress(libWtsapi32, "WTSRegisterSessionNotification");
  56             if (fn_WTSRegisterSessionNotification) {
  57                 HWND hwnd = AwtToolkit::GetInstance().GetHWnd();
  58                 //used for UserSessionListener
  59                 fn_WTSRegisterSessionNotification(hwnd, NOTIFY_FOR_THIS_SESSION);
  60             }
  61         }
  62     }
  63 }
  64     
  65 /*
  66  * Class:     sun_awt_windows_WDesktopPeer
  67  * Method:    ShellExecute
  68  * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
  69  */
  70 JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute
  71   (JNIEnv *env, jclass cls, jstring fileOrUri_j, jstring verb_j)
  72 {
  73     LPCWSTR fileOrUri_c = JNU_GetStringPlatformChars(env, fileOrUri_j, JNI_FALSE);
  74     CHECK_NULL_RETURN(fileOrUri_c, NULL);
  75     LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, JNI_FALSE);
  76     if (verb_c == NULL) {
  77         JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
  78         return NULL;
  79     }
  80 
  81     // 6457572: ShellExecute possibly changes FPU control word - saving it here
  82     unsigned oldcontrol87 = _control87(0, 0);
  83     HINSTANCE retval = ::ShellExecute(NULL, verb_c, fileOrUri_c, NULL, NULL, SW_SHOWNORMAL);
  84     DWORD error = ::GetLastError();


< prev index next >