summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Cornu <ccornu>2002-10-24 22:54:19 +0000
committerChristophe Cornu <ccornu>2002-10-24 22:54:19 +0000
commitb6ee68b9d247b2a1f0204fa3040b53fccbfe63fa (patch)
tree513a1d35dd334f59a716f6257bea87e5449ab2b8
parent240f56afd105ea12aa1961209ae90c16c31a6ffe (diff)
downloadeclipse.platform.swt-b6ee68b9d247b2a1f0204fa3040b53fccbfe63fa.tar.gz
eclipse.platform.swt-b6ee68b9d247b2a1f0204fa3040b53fccbfe63fa.tar.xz
eclipse.platform.swt-b6ee68b9d247b2a1f0204fa3040b53fccbfe63fa.zip
remove fix for PR18855
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c186
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java186
4 files changed, 18 insertions, 414 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
index 64fe567f08..f2ef4d831d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
@@ -22,7 +22,7 @@ WS_PREFIX=win32
SWT_VERSION = $(maj_ver)$(min_ver)
SWT_LIB = $(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).dll
-LINK_LIBS = ole32.lib comctl32.lib user32.lib gdi32.lib comdlg32.lib kernel32.lib shell32.lib oleaut32.lib advapi32.lib imm32.lib winspool.lib oleacc.lib version.lib
+LINK_LIBS = ole32.lib comctl32.lib user32.lib gdi32.lib comdlg32.lib kernel32.lib shell32.lib oleaut32.lib advapi32.lib imm32.lib winspool.lib oleacc.lib
# note: thoroughly test all examples after changing any optimization flags
SWT_CDEBUG = #-Zi -Odi
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
index ae77d042c1..0a58d21922 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
@@ -64,10 +64,6 @@
#define NO_GetDIBits
#define NO_GetFileTitleA
#define NO_GetFileTitleW
-#define NO_GetFileVersionInfoA
-#define NO_GetFileVersionInfoW
-#define NO_GetFileVersionInfoSizeA
-#define NO_GetFileVersionInfoSizeW
#define NO_GetFontLanguageInfo
#define NO_GetIconInfo
#define NO_GetKeyboardLayout
@@ -119,8 +115,6 @@
#define NO_LoadIconA
#define NO_LoadImageA
#define NO_LoadLibraryA
-#define NO_LoadLibraryExA
-#define NO_LoadStringA
#define NO_MapVirtualKeyA
#define NO_MessageBoxA
#define NO_MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I
@@ -201,8 +195,6 @@
#define NO_TranslateAcceleratorA
#define NO_UnhookWindowsHookEx
#define NO_UnregisterClassA
-#define NO_VerQueryValueA
-#define NO_VerQueryValueW
#define NO_VkKeyScanA
#define NO_VkKeyScanW
#define NO_WaitMessage
@@ -2200,76 +2192,6 @@ JNIEXPORT jshort JNICALL OS_NATIVE(GetFileTitleW)
}
#endif /* NO_GetFileTitleW */
-#ifndef NO_GetFileVersionInfoA
-JNIEXPORT jint JNICALL OS_NATIVE(GetFileVersionInfoA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2, jint arg3)
-{
- jbyte *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("GetFileVersionInfoA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jint)GetFileVersionInfoA((LPSTR)lparg0, arg1, arg2, (LPVOID)arg3);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_GetFileVersionInfoA */
-
-#ifndef NO_GetFileVersionInfoSizeA
-JNIEXPORT jint JNICALL OS_NATIVE(GetFileVersionInfoSizeA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jintArray arg1)
-{
- jbyte *lparg0=NULL;
- jint *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetFileVersionInfoSizeA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- rc = (jint)GetFileVersionInfoSizeA((LPSTR)lparg0, lparg1);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetFileVersionInfoSizeA */
-
-#ifndef NO_GetFileVersionInfoSizeW
-JNIEXPORT jint JNICALL OS_NATIVE(GetFileVersionInfoSizeW)
- (JNIEnv *env, jclass that, jcharArray arg0, jintArray arg1)
-{
- jchar *lparg0=NULL;
- jint *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetFileVersionInfoSizeW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- rc = (jint)GetFileVersionInfoSizeW((LPWSTR)lparg0, lparg1);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetFileVersionInfoSizeW */
-
-#ifndef NO_GetFileVersionInfoW
-JNIEXPORT jint JNICALL OS_NATIVE(GetFileVersionInfoW)
- (JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jint arg2, jint arg3)
-{
- jchar *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("GetFileVersionInfoW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- rc = (jint)GetFileVersionInfoW((LPWSTR)lparg0, arg1, arg2, (LPVOID)arg3);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_GetFileVersionInfoW */
-
#ifndef NO_GetFocus
JNIEXPORT jint JNICALL OS_NATIVE(GetFocus)
(JNIEnv *env, jclass that)
@@ -4165,70 +4087,6 @@ JNIEXPORT jint JNICALL OS_NATIVE(LoadLibraryW)
}
#endif /* NO_LoadLibraryW */
-#ifndef NO_LoadLibraryExA
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadLibraryExA
- (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2)
-{
- jbyte *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("LoadLibraryExA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jint)LoadLibraryExA((LPSTR)lparg0, (HANDLE)arg1, arg2);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_LoadLibraryExA */
-
-#ifndef NO_LoadLibraryExW
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadLibraryExW
- (JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jint arg2)
-{
- jchar *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("LoadLibraryExW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- rc = (jint)LoadLibraryExW((LPWSTR)lparg0, (HANDLE)arg1, arg2);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_LoadLibraryExW */
-
-#ifndef NO_LoadStringA
-JNIEXPORT jint JNICALL OS_NATIVE(LoadStringA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
-{
- jbyte *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("LoadStringA\n")
-
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- rc = (jint)LoadStringA((HINSTANCE)arg0, arg1, (LPTSTR)lparg2, arg3);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_LoadStringA */
-
-#ifndef NO_LoadStringW
-JNIEXPORT jint JNICALL OS_NATIVE(LoadStringW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3)
-{
- jchar *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("LoadStringW\n")
-
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- rc = (jint)LoadStringW((HINSTANCE)arg0, arg1, (LPWSTR)lparg2, arg3);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_LoadStringW */
-
#ifndef NO_MapVirtualKeyA
JNIEXPORT jint JNICALL OS_NATIVE(MapVirtualKeyA)
(JNIEnv *env, jclass that, jint arg0, jint arg1)
@@ -7341,50 +7199,6 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(ValidateRect)
}
#endif /* NO_ValidateRect */
-#ifndef NO_VerQueryValueA
-JNIEXPORT jboolean JNICALL OS_NATIVE(VerQueryValueA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jintArray arg2, jintArray arg3)
-{
- jbyte *lparg1=NULL;
- jint *lparg2=NULL;
- jint *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("VerQueryValueA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jboolean)VerQueryValueA((LPVOID)arg0, (LPTSTR)lparg1, (LPVOID *)lparg2, (PUINT)lparg3);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_VerQueryValueA */
-
-#ifndef NO_VerQueryValueW
-JNIEXPORT jboolean JNICALL OS_NATIVE(VerQueryValueW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jintArray arg2, jintArray arg3)
-{
- jchar *lparg1=NULL;
- jint *lparg2=NULL;
- jint *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("VerQueryValueW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jboolean)VerQueryValueW((LPVOID)arg0, (LPWSTR)lparg1, (LPVOID *)lparg2, (PUINT)lparg3);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_VerQueryValueW */
-
#ifndef NO_VkKeyScanA
JNIEXPORT jshort JNICALL OS_NATIVE(VkKeyScanA)
(JNIEnv *env, jclass that, jshort arg0)
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 ea341186e9..11102f0dae 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
@@ -484,7 +484,6 @@ public class OS {
public static final int LGRPID_HEBREW = 0xc;
public static final int LGRPID_INSTALLED = 1;
public static final int LCID_SUPPORTED = 0x2;
- public static final int LOAD_LIBRARY_AS_DATAFILE = 0x2;
public static final int LOCALE_IDEFAULTANSICODEPAGE = 0x1004;
public static final int LOCALE_SISO3166CTRYNAME = 0x5a;
public static final int LOCALE_SISO639LANGNAME = 0x59;
@@ -1427,24 +1426,6 @@ public static final short GetFileTitle (TCHAR lpszFile, TCHAR lpszTitle, short c
return GetFileTitleA (lpszFile1, lpszTitle1, cbBuf);
}
-public static final int GetFileVersionInfo (TCHAR lptstrFileName, int dwHandle, int dwLen, int lpData) {
- if (IsUnicode) {
- char [] lptstrFileName1 = lptstrFileName == null ? null : lptstrFileName.chars;
- return GetFileVersionInfoW (lptstrFileName1, dwHandle, dwLen, lpData);
- }
- byte [] lptstrFileName1 = lptstrFileName == null ? null : lptstrFileName.bytes;
- return GetFileVersionInfoA (lptstrFileName1, dwHandle, dwLen, lpData);
-}
-
-public static final int GetFileVersionInfoSize (TCHAR lptstrFileName, int [] lpdwHandle) {
- if (IsUnicode) {
- char [] lptstrFileName1 = lptstrFileName == null ? null : lptstrFileName.chars;
- return GetFileVersionInfoSizeW (lptstrFileName1, lpdwHandle);
- }
- byte [] lptstrFileName1 = lptstrFileName == null ? null : lptstrFileName.bytes;
- return GetFileVersionInfoSizeA (lptstrFileName1, lpdwHandle);
-}
-
public static final int GetLocaleInfo (int Locale, int LCType, TCHAR lpLCData, int cchData) {
if (IsUnicode) {
char [] lpLCData1 = lpLCData == null ? null : lpLCData.chars;
@@ -1627,24 +1608,6 @@ public static final int LoadLibrary (TCHAR lpLibFileName) {
return LoadLibraryA (lpLibFileName1);
}
-public static final int LoadLibraryEx (TCHAR lpFileName, int hFile, int dwFlags) {
- if (IsUnicode) {
- char [] lpFileName1 = lpFileName == null ? null : lpFileName.chars;
- return LoadLibraryExW (lpFileName1, hFile, dwFlags);
- }
- byte [] lpFileName1 = lpFileName == null ? null : lpFileName.bytes;
- return LoadLibraryExA (lpFileName1, hFile, dwFlags);
-}
-
-public static final int LoadString (int hInstance, int uID, TCHAR lpBuffer, int nBufferMax) {
- if (IsUnicode) {
- char [] lpBuffer1 = lpBuffer == null ? null : lpBuffer.chars;
- return LoadStringW (hInstance, uID, lpBuffer1, nBufferMax);
- }
- byte [] lpBuffer1 = lpBuffer == null ? null : lpBuffer.bytes;
- return LoadStringA (hInstance, uID, lpBuffer1, nBufferMax);
-}
-
public static final int MapVirtualKey (int uCode, int uMapType) {
if (IsUnicode) return MapVirtualKeyW (uCode, uMapType);
return MapVirtualKeyA (uCode, uMapType);
@@ -1954,16 +1917,6 @@ public static final boolean UnregisterClass (TCHAR lpClassName, int hInstance) {
return UnregisterClassA (lpClassName1, hInstance);
}
-public static final boolean VerQueryValue (int pBlock, TCHAR lpSubBlock, int[] lplpBuffer, int[] puLen) {
- if (IsUnicode) {
- char [] lpSubBlock1 = lpSubBlock == null ? null : lpSubBlock.chars;
- return VerQueryValueW (pBlock, lpSubBlock1, lplpBuffer, puLen);
- }
- byte [] lpSubBlock1 = lpSubBlock == null ? null : lpSubBlock.bytes;
- return VerQueryValueA (pBlock, lpSubBlock1, lplpBuffer, puLen);
-}
-
-
public static final short VkKeyScan (short ch) {
if (IsUnicode) return VkKeyScanW (ch);
return VkKeyScanA (ch);
@@ -2115,10 +2068,6 @@ public static final native int GetDlgItem (int hDlg, int nIDDlgItem);
public static final native int GetDoubleClickTime ();
public static final native short GetFileTitleW (char [] lpszFile, char [] lpszTitle, short cbBuf);
public static final native short GetFileTitleA (byte [] lpszFile, byte [] lpszTitle, short cbBuf);
-public static final native int GetFileVersionInfoA (byte [] lptstrFileName, int dwHandle, int dwLen, int lpData);
-public static final native int GetFileVersionInfoW (char [] lptstrFileName, int dwHandle, int dwLen, int lpData);
-public static final native int GetFileVersionInfoSizeA (byte [] lptstrFileName, int [] lpdwHandle);
-public static final native int GetFileVersionInfoSizeW (char [] lptstrFileName, int [] lpdwHandle);
public static final native int GetFocus ();
public static final native int GetFontLanguageInfo(int hdc);
public static final native boolean GetIconInfo (int hIcon, ICONINFO piconinfo);
@@ -2262,10 +2211,6 @@ public static final native int LoadImageW (int hinst, char [] lpszName, int uTyp
public static final native int LoadImageA (int hinst, byte [] lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
public static final native int LoadLibraryW (char [] lpLibFileName);
public static final native int LoadLibraryA (byte [] lpLibFileName);
-public static final native int LoadLibraryExW (char [] lpFileName, int hFile, int dwFlags);
-public static final native int LoadLibraryExA (byte [] lpFileName, int hFile, int dwFlags);
-public static final native int LoadStringW (int hInstance, int uID, char [] lpBuffer, int nBufferMax);
-public static final native int LoadStringA (int hInstance, int uID, byte [] lpBuffer, int nBufferMax);
public static final native int MapVirtualKeyW (int uCode, int uMapType);
public static final native int MapVirtualKeyA (int uCode, int uMapType);
public static final native int MapWindowPoints (int hWndFrom, int hWndTo, POINT lpPoints, int cPoints);
@@ -2476,9 +2421,6 @@ public static final native boolean UnregisterClassW (char [] lpClassName, int hI
public static final native boolean UnregisterClassA (byte [] lpClassName, int hInstance);
public static final native boolean UpdateWindow (int hWnd);
public static final native boolean ValidateRect (int hWnd, RECT lpRect);
-public static final native boolean VerQueryValueW (int pBlock, char [] lpSubBlock, int [] lplpBuffer, int [] puLen);
-public static final native boolean VerQueryValueA (int pBlock, byte [] lpSubBlock, int [] lplpBuffer, int [] puLen);
-
public static final native short VkKeyScanW (short ch);
public static final native short VkKeyScanA (short ch);
public static final native int VtblCall (int ppVtbl, int fnNumber, int arg0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
index c9b72b4bd6..d9d166de9a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
@@ -1,9 +1,9 @@
package org.eclipse.swt.program;
/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*/
@@ -92,60 +92,19 @@ public static String [] getExtensions () {
return extensions;
}
-static Program [] getFileClassPrograms () {
- Program [] programs = new Program [128];
- /* Use the character encoding for the default locale */
- TCHAR lpName = new TCHAR (0, 1024);
- int [] lpcName = new int [] {lpName.length ()};
- FILETIME ft = new FILETIME ();
- int dwIndex = 0, count = 0;
- while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
- String path = lpName.toString (0, lpcName [0]);
- lpcName [0] = lpName.length ();
- Program program = getProgram (path);
- if (program != null) {
- /* Make sure the name is unique */
- boolean isDuplicate = false;
- for (int i = 0; i < count; i++) {
- String value = programs [i].name;
- if (value.equalsIgnoreCase (program.name)) {
- isDuplicate = true;
- break;
- }
- }
- if (!isDuplicate) {
- if (count == programs.length) {
- Program [] newPrograms = new Program [programs.length + 128];
- System.arraycopy (programs, 0, newPrograms, 0, programs.length);
- programs = newPrograms;
- }
- programs [count++] = program;
- }
- }
- dwIndex++;
- }
- if (count != programs.length) {
- Program [] newPrograms = new Program [count];
- System.arraycopy (programs, 0, newPrograms, 0, count);
- programs = newPrograms;
- }
- return programs;
-}
-
-static String getKeyValue (String string, String value, boolean expand) {
+static String getKeyValue (String string, boolean expand) {
/* Use the character encoding for the default locale */
TCHAR key = new TCHAR (0, string, true);
int [] phkResult = new int [1];
if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
return null;
}
- TCHAR lpValueName = value == null ? null : new TCHAR (0, value, true);
String result = null;
int [] lpcbData = new int [1];
- if (OS.RegQueryValueEx (phkResult [0], lpValueName, 0, null, null, lpcbData) == 0) {
+ if (OS.RegQueryValueEx (phkResult [0], (TCHAR) null, 0, null, null, lpcbData) == 0) {
/* Use the character encoding for the default locale */
TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
- if (OS.RegQueryValueEx (phkResult [0], lpValueName, 0, null, lpData, lpcbData) == 0) {
+ if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
if (!OS.IsWinCE && expand) {
int nSize = OS.ExpandEnvironmentStrings (lpData, null, 0);
TCHAR lpDst = new TCHAR (0, nSize);
@@ -162,18 +121,19 @@ static String getKeyValue (String string, String value, boolean expand) {
}
static Program getProgram (String key) {
+
+ /* Name */
+ String name = getKeyValue (key, false);
+ if (name == null || name.length () == 0) return null;
/* Command */
String COMMAND = "\\shell\\open\\command";
- String command = getKeyValue (key + COMMAND, null, true);
+ String command = getKeyValue (key + COMMAND, true);
if (command == null || command.length () == 0) return null;
- /* Name */
- String name = getProgramName(key, command);
- if (name == null || name.length () == 0) return null;
-
/* Icon */
- String iconName = getProgramPath(command);
+ String DEFAULT_ICON = "\\DefaultIcon";
+ String iconName = getKeyValue (key + DEFAULT_ICON, true);
if (iconName == null || iconName.length () == 0) return null;
Program program = new Program ();
@@ -189,39 +149,19 @@ static Program getProgram (String key) {
* @return an array of programs
*/
public static Program [] getPrograms () {
- /*
- * The Windows registry maintains a list of file extensions and their related
- * editors. In addition, W2K and XP maintain a list of applications which can
- * be used to populate the 'Open As' dialog. 2 articles in MSDN describe this
- * mechanism: 'File Associations: Arbitrary File Types' and 'Creating a File
- * Association'.
- * There does not seem to be an API to retrieve the list of programs in the
- * 'Open As' dialog. As a result, on W2K machines and above, we look up the
- * registry as described in the articles above. On Win95 and NT machines, we use
- * the list of applications registered to one or more file classes.
- */
- if (OS.IsWin95) return getFileClassPrograms ();
- if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) return getFileClassPrograms ();
- String KEY = "Applications";
- /* Use the character encoding for the default locale */
- TCHAR key = new TCHAR (0, KEY, true);
- int [] phkResult = new int [1];
- if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
- return new Program [0];
- }
- Program [] programs = new Program [128];
+ Program [] programs = new Program [1024];
/* Use the character encoding for the default locale */
TCHAR lpName = new TCHAR (0, 1024);
int [] lpcName = new int [] {lpName.length ()};
FILETIME ft = new FILETIME ();
int dwIndex = 0, count = 0;
- while (OS.RegEnumKeyEx (phkResult[0], dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
- String path = KEY + "\\" + lpName.toString (0, lpcName [0]);
+ while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
+ String path = lpName.toString (0, lpcName [0]);
lpcName [0] = lpName.length ();
Program program = getProgram (path);
if (program != null) {
if (count == programs.length) {
- Program [] newPrograms = new Program [programs.length + 128];
+ Program [] newPrograms = new Program [programs.length + 1024];
System.arraycopy (programs, 0, newPrograms, 0, programs.length);
programs = newPrograms;
}
@@ -237,98 +177,6 @@ public static Program [] getPrograms () {
return programs;
}
-static String getProgramName (String key, String command) {
- String FRIENDLYAPPNAME = "FriendlyAppName";
- /* The FriendlyAppName registry key contains the application name
- * and must be searched first. It can be missing. */
- String name = getKeyValue (key, FRIENDLYAPPNAME, true);
- if (name != null) {
- /* The value is either a string or a reference to a resource
- * string located in an exe or dll. */
- if (name.charAt (0) == '@') {
- int nResourceIndex = 0;
- String fileName = name;
- int index = name.indexOf (',');
- if (index != -1) {
- fileName = name.substring (1, index);
- String resourceIndex = name.substring (index + 1, name.length ()).trim ();
- try {
- nResourceIndex = Integer.parseInt (resourceIndex);
- } catch (NumberFormatException e) {};
- }
- name = null;
- /* Use the character encoding for the default locale */
- TCHAR lpFileName = new TCHAR (0, fileName, true);
- int hInstance = OS.LoadLibraryEx (lpFileName, 0, OS.LOAD_LIBRARY_AS_DATAFILE);
- if (hInstance != 0) {
- if (nResourceIndex < 0) nResourceIndex = -nResourceIndex;
- int nBufferMax = 1024;
- TCHAR lpBuffer = new TCHAR (0, nBufferMax);
- int nbr = OS.LoadString (hInstance, nResourceIndex, lpBuffer, nBufferMax);
- if (nbr != 0) name = lpBuffer.toString (0, nbr);
- OS.FreeLibrary (hInstance);
- }
- }
- if (name != null && name.length () != 0) return name;
- }
- /* Get the friendly name in the version information of the executable */
- String path = getProgramPath (command);
- if (path == null) return null;
- TCHAR lptstrFileName = new TCHAR (0, path, true);
- int [] lpdwHandle = new int [1];
- int size = OS.GetFileVersionInfoSize (lptstrFileName, lpdwHandle);
- if (size != 0) {
- String langCodepage = null;
- int hHeap = OS.GetProcessHeap ();
- int lpData = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, size);
- if (OS.GetFileVersionInfo(lptstrFileName, 0, size, lpData) != 0) {
- int[] lplpBuffer = new int [1];
- int[] puLen = new int [1];
- short[] codes = new short [2];
- /* Get the hexadecimal string representing the language and codepage
- * used by the String table
- */
- if (OS.VerQueryValue(lpData, new TCHAR(0, "\\VarFileInfo\\Translation", true), lplpBuffer, puLen)) {
- if (puLen [0] == 4 && lplpBuffer [0] != 0) {
- OS.MoveMemory(codes, lplpBuffer [0], 4);
- String data = Integer.toHexString(codes [0] & 0xffff);
- while (data.length () < 4) data = "0" + data;
- langCodepage = data;
- data = Integer.toHexString (codes [1] & 0xffff);
- while (data.length () < 4) data = "0" + data;
- langCodepage += data;
- }
- }
- if (langCodepage != null) {
- TCHAR lpSubBlock = new TCHAR (0, "\\StringFileInfo\\" + langCodepage + "\\FileDescription", true);
- if (OS.VerQueryValue(lpData, lpSubBlock, lplpBuffer, puLen)) {
- if (lplpBuffer [0] != 0 && puLen [0] != 0) {
- TCHAR description = new TCHAR(0, puLen [0]);
- OS.MoveMemory(description, lplpBuffer [0], puLen [0] * TCHAR.sizeof);
- name = description.toString (0, description.strlen());
- }
- }
- }
- }
- if (lpData != 0) OS.HeapFree (hHeap, 0, lpData);
- }
- return name;
-}
-
-static String getProgramPath (String command) {
- String path = null;
- /*
- * Parse the command which may contain quotes and parameters.
- * Remove the leading quote if any, and ignore everything
- * following the executable extension. If the command does not
- * refer to an executable (.exe file only), return null. */
- int start = command.charAt (0) != '"' ? 0 : 1;
- String extension = ".exe";
- int index = command.toLowerCase ().indexOf (extension);
- if (index > start) path = command.substring (start, index + extension.length ());
- return path;
-}
-
/**
* Launches the executable associated with the file in
* the operating system. If the file is an executable,