diff options
5 files changed, 266 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java index 44097861d0..b68fbb9171 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java @@ -40,6 +40,7 @@ class IE extends WebBrowser { int style, lastKeyCode, lastCharCode; int lastMouseMoveX, lastMouseMoveY; + static boolean Initialized; static int IEVersion, PDFCount; static String ProgId = "Shell.Explorer"; //$NON-NLS-1$ @@ -105,9 +106,13 @@ class IE extends WebBrowser { static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$ static final String CLSID_SHELLEXPLORER1 = "{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B}"; //$NON-NLS-1$ + static final int DEFAULT_IE_VERSION = 9000; static final String EXTENSION_PDF = ".pdf"; //$NON-NLS-1$ static final String HTML_DOCUMENT = "HTML Document"; //$NON-NLS-1$ static final int MAX_PDF = 20; + static final char SEPARATOR_OS = System.getProperty ("file.separator").charAt (0); //$NON-NLS-1$ + static final String PROPERTY_IEVERSION = "org.eclipse.swt.browser.IEVersion"; //$NON-NLS-1$ + static final String VALUE_DEFAULT = "default"; //$NON-NLS-1$ static final String EVENT_DOUBLECLICK = "dblclick"; //$NON-NLS-1$ static final String EVENT_DRAGEND = "dragend"; //$NON-NLS-1$ @@ -137,7 +142,6 @@ class IE extends WebBrowser { static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$ static final String PROPERTY_WHEELDELTA = "wheelDelta"; //$NON-NLS-1$ - static { NativeClearSessions = new Runnable() { public void run() { @@ -265,7 +269,60 @@ public void create(Composite parent, int style) { browser.dispose(); SWT.error(SWT.ERROR_NO_HANDLES); } - + + if (!Initialized) { + Initialized = true; + int version = 0; + String versionProperty = System.getProperty(PROPERTY_IEVERSION); + if (versionProperty != null) { + if (versionProperty.equalsIgnoreCase(VALUE_DEFAULT)) { + version = -1; + } else { + try { + version = Integer.valueOf(versionProperty).intValue(); + } catch (NumberFormatException e) { + /* + * An invalid value was specified for the IEVersion java property. Ignore it + * and continue with the usual steps for determining the version to specify. + */ + } + } + } + if (version == 0) { + if (IEVersion != 0) { + version = IEVersion * 1000; + } else { + version = DEFAULT_IE_VERSION; + } + } + + if (version != -1) { + int /*long*/[] key = new int /*long*/[1]; + final TCHAR subkey = new TCHAR(0, "Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true); //$NON-NLS-1$ + if (OS.RegCreateKeyEx(OS.HKEY_CURRENT_USER, subkey, 0, null, OS.REG_OPTION_VOLATILE, OS.KEY_WRITE | OS.KEY_QUERY_VALUE, 0, key, null) == 0) { + TCHAR lpszFile = new TCHAR(0, OS.MAX_PATH); + OS.GetModuleFileName(0, lpszFile, lpszFile.length()); + String path = lpszFile.toString(0, lpszFile.strlen()); + int index = path.lastIndexOf(SEPARATOR_OS); + String executable = index != -1 ? path.substring(index + 1) : path; + final TCHAR lpValueName = new TCHAR(0, executable, true); + if (OS.RegQueryValueEx(key[0], lpValueName, 0, null, (int[])null, null) == OS.ERROR_FILE_NOT_FOUND) { + if (OS.RegSetValueEx(key[0], lpValueName, 0, OS.REG_DWORD, new int[] {version}, 4) == 0) { + parent.getDisplay().addListener(SWT.Dispose, new Listener() { + public void handleEvent(Event event) { + int /*long*/[] key = new int /*long*/[1]; + if (OS.RegOpenKeyEx(OS.HKEY_CURRENT_USER, subkey, 0, OS.KEY_WRITE, key) == 0) { + OS.RegDeleteValue(key[0], lpValueName); + } + } + }); + } + } + OS.RegCloseKey(key[0]); + } + } + } + site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); auto = new OleAutomation(site); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c index b6903a22d5..31e8d5c765 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c @@ -12634,6 +12634,88 @@ JNIEXPORT jint JNICALL OS_NATIVE(RegCloseKey) } #endif +#ifndef NO_RegCreateKeyExA +JNIEXPORT jint JNICALL OS_NATIVE(RegCreateKeyExA) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jint arg2, jbyteArray arg3, jint arg4, jint arg5, jintLong arg6, jintLongArray arg7, jintLongArray arg8) +{ + jbyte *lparg1=NULL; + jbyte *lparg3=NULL; + jintLong *lparg7=NULL; + jintLong *lparg8=NULL; + jint rc = 0; + OS_NATIVE_ENTER(env, that, RegCreateKeyExA_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail; + if (arg7) if ((lparg7 = (*env)->GetIntLongArrayElements(env, arg7, NULL)) == NULL) goto fail; + if (arg8) if ((lparg8 = (*env)->GetIntLongArrayElements(env, arg8, NULL)) == NULL) goto fail; + rc = (jint)RegCreateKeyExA((HKEY)arg0, (LPSTR)lparg1, arg2, (LPTSTR)lparg3, arg4, arg5, (LPSECURITY_ATTRIBUTES)arg6, (PHKEY)lparg7, (LPDWORD)lparg8); +fail: + if (arg8 && lparg8) (*env)->ReleaseIntLongArrayElements(env, arg8, lparg8, 0); + if (arg7 && lparg7) (*env)->ReleaseIntLongArrayElements(env, arg7, lparg7, 0); + if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0); + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, RegCreateKeyExA_FUNC); + return rc; +} +#endif + +#ifndef NO_RegCreateKeyExW +JNIEXPORT jint JNICALL OS_NATIVE(RegCreateKeyExW) + (JNIEnv *env, jclass that, jintLong arg0, jcharArray arg1, jint arg2, jcharArray arg3, jint arg4, jint arg5, jintLong arg6, jintLongArray arg7, jintLongArray arg8) +{ + jchar *lparg1=NULL; + jchar *lparg3=NULL; + jintLong *lparg7=NULL; + jintLong *lparg8=NULL; + jint rc = 0; + OS_NATIVE_ENTER(env, that, RegCreateKeyExW_FUNC); + if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL)) == NULL) goto fail; + if (arg7) if ((lparg7 = (*env)->GetIntLongArrayElements(env, arg7, NULL)) == NULL) goto fail; + if (arg8) if ((lparg8 = (*env)->GetIntLongArrayElements(env, arg8, NULL)) == NULL) goto fail; + rc = (jint)RegCreateKeyExW((HKEY)arg0, (LPWSTR)lparg1, arg2, (LPWSTR)lparg3, arg4, arg5, (LPSECURITY_ATTRIBUTES)arg6, (PHKEY)lparg7, (LPDWORD)lparg8); +fail: + if (arg8 && lparg8) (*env)->ReleaseIntLongArrayElements(env, arg8, lparg8, 0); + if (arg7 && lparg7) (*env)->ReleaseIntLongArrayElements(env, arg7, lparg7, 0); + if (arg3 && lparg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0); + if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, RegCreateKeyExW_FUNC); + return rc; +} +#endif + +#ifndef NO_RegDeleteValueA +JNIEXPORT jint JNICALL OS_NATIVE(RegDeleteValueA) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + jint rc = 0; + OS_NATIVE_ENTER(env, that, RegDeleteValueA_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; + rc = (jint)RegDeleteValueA((HKEY)arg0, (LPSTR)lparg1); +fail: + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, RegDeleteValueA_FUNC); + return rc; +} +#endif + +#ifndef NO_RegDeleteValueW +JNIEXPORT jint JNICALL OS_NATIVE(RegDeleteValueW) + (JNIEnv *env, jclass that, jintLong arg0, jcharArray arg1) +{ + jchar *lparg1=NULL; + jint rc = 0; + OS_NATIVE_ENTER(env, that, RegDeleteValueW_FUNC); + if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail; + rc = (jint)RegDeleteValueW((HKEY)arg0, (LPWSTR)lparg1); +fail: + if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, RegDeleteValueW_FUNC); + return rc; +} +#endif + #ifndef NO_RegEnumKeyExA JNIEXPORT jint JNICALL OS_NATIVE(RegEnumKeyExA) (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jbyteArray arg2, jintArray arg3, jintArray arg4, jbyteArray arg5, jintArray arg6, jobject arg7) @@ -12952,6 +13034,44 @@ fail: } #endif +#ifndef NO_RegSetValueExA +JNIEXPORT jint JNICALL OS_NATIVE(RegSetValueExA) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jint arg2, jint arg3, jintArray arg4, jint arg5) +{ + jbyte *lparg1=NULL; + jint *lparg4=NULL; + jint rc = 0; + OS_NATIVE_ENTER(env, that, RegSetValueExA_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail; + rc = (jint)RegSetValueExA((HKEY)arg0, (LPSTR)lparg1, arg2, arg3, (const BYTE*)lparg4, arg5); +fail: + if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, RegSetValueExA_FUNC); + return rc; +} +#endif + +#ifndef NO_RegSetValueExW +JNIEXPORT jint JNICALL OS_NATIVE(RegSetValueExW) + (JNIEnv *env, jclass that, jintLong arg0, jcharArray arg1, jint arg2, jint arg3, jintArray arg4, jint arg5) +{ + jchar *lparg1=NULL; + jint *lparg4=NULL; + jint rc = 0; + OS_NATIVE_ENTER(env, that, RegSetValueExW_FUNC); + if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail; + rc = (jint)RegSetValueExW((HKEY)arg0, (LPWSTR)lparg1, arg2, arg3, (const BYTE*)lparg4, arg5); +fail: + if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, RegSetValueExW_FUNC); + return rc; +} +#endif + #ifndef NO_RegisterClassA JNIEXPORT jint JNICALL OS_NATIVE(RegisterClassA) (JNIEnv *env, jclass that, jobject arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c index 07feae7f35..661e1110ca 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c @@ -14,8 +14,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 1053; -int OS_nativeFunctionCallCount[1053]; +int OS_nativeFunctionCount = 1059; +int OS_nativeFunctionCallCount[1059]; char * OS_nativeFunctionNames[] = { "ACCEL_1sizeof", "ACTCTX_1sizeof", @@ -1256,6 +1256,10 @@ char * OS_nativeFunctionNames[] = { "Rectangle", "RedrawWindow", "RegCloseKey", + "RegCreateKeyExA", + "RegCreateKeyExW", + "RegDeleteValueA", + "RegDeleteValueW", "RegEnumKeyExA", "RegEnumKeyExW", "RegOpenKeyExA", @@ -1282,6 +1286,8 @@ char * OS_nativeFunctionNames[] = { #else "RegQueryValueExW__J_3CJ_3I_3I_3I", #endif + "RegSetValueExA", + "RegSetValueExW", "RegisterClassA", "RegisterClassW", "RegisterClipboardFormatA", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h index c01f710f41..9bd7930ced 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h @@ -1264,6 +1264,10 @@ typedef enum { Rectangle_FUNC, RedrawWindow_FUNC, RegCloseKey_FUNC, + RegCreateKeyExA_FUNC, + RegCreateKeyExW_FUNC, + RegDeleteValueA_FUNC, + RegDeleteValueW_FUNC, RegEnumKeyExA_FUNC, RegEnumKeyExW_FUNC, RegOpenKeyExA_FUNC, @@ -1290,6 +1294,8 @@ typedef enum { #else RegQueryValueExW__J_3CJ_3I_3I_3I_FUNC, #endif + RegSetValueExA_FUNC, + RegSetValueExW_FUNC, RegisterClassA_FUNC, RegisterClassW_FUNC, RegisterClipboardFormatA_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index d6cdfe61f8..12021c19a2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -649,6 +649,7 @@ public class OS extends C { public static final int EN_ALIGN_RTL_EC = 0x0701; public static final int EN_CHANGE = 0x300; public static final int EP_EDITTEXT = 1; + public static final int ERROR_FILE_NOT_FOUND = 0x2; public static final int ERROR_NO_MORE_ITEMS = 0x103; public static final int ESB_DISABLE_BOTH = 0x3; public static final int ESB_ENABLE_BOTH = 0x0; @@ -906,6 +907,7 @@ public class OS extends C { public static final int KEY_NOTIFY = 0x10; public static final int KEY_QUERY_VALUE = 0x1; public static final int KEY_READ = 0x20019; + public static final int KEY_WRITE = 0x20006; public static final int KEYEVENTF_EXTENDEDKEY = 0x0001; public static final int KEYEVENTF_KEYUP = 0x0002; public static final int L_MAX_URL_LENGTH = 2084; @@ -1433,6 +1435,8 @@ public class OS extends C { public static final int RDW_UPDATENOW = 0x100; public static final int READ_CONTROL = 0x20000; public static final String REBARCLASSNAME = "ReBarWindow32"; //$NON-NLS-1$ + public static final int REG_DWORD = 4; + public static final int REG_OPTION_VOLATILE = 0x1; public static final int RGN_AND = 0x1; public static final int RGN_COPY = 5; public static final int RGN_DIFF = 0x4; @@ -3107,6 +3111,26 @@ public static final boolean PrintDlg (PRINTDLG lppd) { return PrintDlgA (lppd); } +public static final int RegCreateKeyEx (int /*long*/ hKey, TCHAR lpSubKey, int Reserved, TCHAR lpClass, int dwOptions, int samDesired, int /*long*/ lpSecurityAttributes, int /*long*/[] phkResult, int /*long*/[] lpdwDisposition) { + if (IsUnicode) { + char [] lpClass1 = lpClass == null ? null : lpClass.chars; + char [] lpSubKey1 = lpSubKey == null ? null : lpSubKey.chars; + return RegCreateKeyExW (hKey, lpSubKey1, Reserved, lpClass1, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition); + } + byte [] lpClass1 = lpClass == null ? null : lpClass.bytes; + byte [] lpSubKey1 = lpSubKey == null ? null : lpSubKey.bytes; + return RegCreateKeyExA (hKey, lpSubKey1, Reserved, lpClass1, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition); +} + +public static final int RegDeleteValue (int /*long*/ hKey, TCHAR lpValueName) { + if (IsUnicode) { + char [] lpValueName1 = lpValueName == null ? null : lpValueName.chars; + return RegDeleteValueW (hKey, lpValueName1); + } + byte [] lpValueName1 = lpValueName == null ? null : lpValueName.bytes; + return RegDeleteValueA (hKey, lpValueName1); +} + public static final int RegEnumKeyEx (int /*long*/ hKey, int dwIndex, TCHAR lpName, int [] lpcName, int [] lpReserved, TCHAR lpClass, int [] lpcClass, FILETIME lpftLastWriteTime) { if (IsUnicode) { char [] lpName1 = lpName == null ? null : lpName.chars; @@ -3175,6 +3199,15 @@ public static final int RegQueryValueEx (int /*long*/ hKey, TCHAR lpValueName, i return RegQueryValueExA (hKey, lpValueName1, lpReserved, lpType, lpData, lpcbData); } +public static final int RegSetValueEx (int /*long*/ hKey, TCHAR lpValueName, int Reserved, int dwType, int[] lpData, int cbData) { + if (IsUnicode) { + char [] lpValueName1 = lpValueName == null ? null : lpValueName.chars; + return RegSetValueExW (hKey, lpValueName1, Reserved, dwType, lpData, cbData); + } + byte [] lpValueName1 = lpValueName == null ? null : lpValueName.bytes; + return RegSetValueExA (hKey, lpValueName1, Reserved, dwType, lpData, cbData); +} + public static final int /*long*/ RemoveProp (int /*long*/ hWnd, int /*long*/ lpString){ if (IsUnicode) return RemovePropW (hWnd, lpString); return RemovePropA (hWnd, lpString); @@ -5705,6 +5738,34 @@ public static final native boolean RedrawWindow (int /*long*/ hWnd, RECT lprcUpd public static final native int RegCloseKey (int /*long*/ hKey); /** * @param hKey cast=(HKEY) + * @param lpSubKey cast=(LPWSTR) + * @param lpClass cast=(LPWSTR) + * @param lpSecurityAttributes cast=(LPSECURITY_ATTRIBUTES) + * @param phkResult cast=(PHKEY) + * @param lpdwDisposition cast=(LPDWORD) + */ +public static final native int RegCreateKeyExW (int /*long*/ hKey, char[] lpSubKey, int Reserved, char[] lpClass, int dwOptions, int samDesired, int /*long*/ lpSecurityAttributes, int /*long*/[] phkResult, int /*long*/[] lpdwDisposition); +/** + * @param hKey cast=(HKEY) + * @param lpSubKey cast=(LPSTR) + * @param lpClass cast=(LPTSTR) + * @param lpSecurityAttributes cast=(LPSECURITY_ATTRIBUTES) + * @param phkResult cast=(PHKEY) + * @param lpdwDisposition cast=(LPDWORD) + */ +public static final native int RegCreateKeyExA (int /*long*/ hKey, byte[] lpSubKey, int Reserved, byte[] lpClass, int dwOptions, int samDesired, int /*long*/ lpSecurityAttributes, int /*long*/[] phkResult, int /*long*/[] lpdwDisposition); +/** + * @param hKey cast=(HKEY) + * @param lpValueName cast=(LPWSTR) + */ +public static final native int RegDeleteValueW (int /*long*/ hKey, char[] lpValueName); +/** + * @param hKey cast=(HKEY) + * @param lpValueName cast=(LPSTR) + */ +public static final native int RegDeleteValueA (int /*long*/ hKey, byte[] lpValueName); +/** + * @param hKey cast=(HKEY) * @param lpName cast=(LPWSTR) * @param lpcName cast=(LPDWORD) * @param lpReserved cast=(LPDWORD) @@ -5809,6 +5870,18 @@ public static final native int RegQueryValueExW (int /*long*/ hKey, char[] lpVal public static final native int RegQueryValueExA (int /*long*/ hKey, byte[] lpValueName, int /*long*/ lpReserved, int[] lpType, byte [] lpData, int[] lpcbData); /** * @param hKey cast=(HKEY) + * @param lpValueName cast=(LPWSTR) + * @param lpData cast=(const BYTE*) + */ +public static final native int RegSetValueExW (int /*long*/ hKey, char[] lpValueName, int Reserved, int dwType, int[] lpData, int cbData); +/** + * @param hKey cast=(HKEY) + * @param lpValueName cast=(LPSTR) + * @param lpData cast=(const BYTE*) + */ +public static final native int RegSetValueExA (int /*long*/ hKey, byte[] lpValueName, int Reserved, int dwType, int[] lpData, int cbData); +/** + * @param hKey cast=(HKEY) * @param lpValueName cast=(LPSTR) * @param lpReserved cast=(LPDWORD) * @param lpType cast=(LPDWORD) |