summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover <steve>2006-09-20 22:43:09 +0000
committerSteve Northover <steve>2006-09-20 22:43:09 +0000
commit9a60b6b1565fd42d06cf1fac650c2f6dd44612e0 (patch)
tree01c63a4efdeac8625654c35b9ba8da1f545715c0
parent99e437fa580702168e537f4a5d7239ece222d7cb (diff)
downloadeclipse.platform.swt-9a60b6b1565fd42d06cf1fac650c2f6dd44612e0.tar.gz
eclipse.platform.swt-9a60b6b1565fd42d06cf1fac650c2f6dd44612e0.tar.xz
eclipse.platform.swt-9a60b6b1565fd42d06cf1fac650c2f6dd44612e0.zip
149774 - [Program] Improve command handling of Program#execute(String) on Win32
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties59
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c78
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c122
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PROCESS_INFORMATION.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/STARTUPINFO.java33
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java46
11 files changed, 392 insertions, 24 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties
index e1a1957bd7..78ebf24066 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties
@@ -805,6 +805,9 @@ OS_ClientToScreen_1=
OS_CloseClipboard=
+OS_CloseHandle=
+OS_CloseHandle_0=cast=HANDLE
+
OS_CloseThemeData=flags=dynamic
OS_CloseThemeData_0=cast=HTHEME
@@ -959,6 +962,30 @@ OS_CreatePolygonRgn_2=
OS_CreatePopupMenu=
+OS_CreateProcessA=
+OS_CreateProcessA_0=cast=(LPCSTR)
+OS_CreateProcessA_1=cast=(LPSTR)
+OS_CreateProcessA_2=cast=(LPSECURITY_ATTRIBUTES)
+OS_CreateProcessA_3=cast=(LPSECURITY_ATTRIBUTES)
+OS_CreateProcessA_4=
+OS_CreateProcessA_5=
+OS_CreateProcessA_6=cast=(LPVOID)
+OS_CreateProcessA_7=cast=(LPSTR)
+OS_CreateProcessA_8=cast=LPSTARTUPINFOA
+OS_CreateProcessA_9=cast=(LPPROCESS_INFORMATION)
+
+OS_CreateProcessW=
+OS_CreateProcessW_0=cast=(LPCWSTR)
+OS_CreateProcessW_1=cast=(LPWSTR)
+OS_CreateProcessW_2=cast=(LPSECURITY_ATTRIBUTES)
+OS_CreateProcessW_3=cast=(LPSECURITY_ATTRIBUTES)
+OS_CreateProcessW_4=
+OS_CreateProcessW_5=
+OS_CreateProcessW_6=cast=(LPVOID)
+OS_CreateProcessW_7=cast=(LPWSTR)
+OS_CreateProcessW_8=cast=LPSTARTUPINFOW
+OS_CreateProcessW_9=cast=(LPPROCESS_INFORMATION)
+
OS_CreateRectRgn=
OS_CreateRectRgn_0=
OS_CreateRectRgn_1=
@@ -1864,6 +1891,12 @@ OS_GetScrollInfo_0=cast=(HWND)
OS_GetScrollInfo_1=
OS_GetScrollInfo_2=
+OS_GetStartupInfoA=
+OS_GetStartupInfoA_0=cast=(LPSTARTUPINFOA)
+
+OS_GetStartupInfoW=
+OS_GetStartupInfoW_0=cast=(LPSTARTUPINFOW)
+
OS_GetStockObject=
OS_GetStockObject_0=
@@ -4240,6 +4273,12 @@ PRINTDLG_lpSetupTemplateName=cast=(LPCTSTR)
PRINTDLG_hPrintTemplate=cast=(HGLOBAL)
PRINTDLG_hSetupTemplate=cast=(HGLOBAL)
+org_eclipse_swt_internal_win32_PROCESS_1INFORMATION=
+PROCESS_INFORMATION_hProcess=cast=HANDLE
+PROCESS_INFORMATION_hThread=cast=HANDLE
+PROCESS_INFORMATION_dwProcessId=
+PROCESS_INFORMATION_dwThreadId=
+
org_eclipse_swt_internal_win32_REBARBANDINFO=
REBARBANDINFO_cbSize=
REBARBANDINFO_fMask=
@@ -4415,6 +4454,26 @@ org_eclipse_swt_internal_win32_SIZE=
SIZE_cx=
SIZE_cy=
+org_eclipse_swt_internal_win32_STARTUPINFO=
+STARTUPINFO_cb=
+STARTUPINFO_lpReserved=cast=LPTSTR
+STARTUPINFO_lpDesktop=cast=LPTSTR
+STARTUPINFO_lpTitle=cast=LPTSTR
+STARTUPINFO_dwX=
+STARTUPINFO_dwY=
+STARTUPINFO_dwXSize=
+STARTUPINFO_dwYSize=
+STARTUPINFO_dwXCountChars=
+STARTUPINFO_dwYCountChars=
+STARTUPINFO_dwFillAttribute=
+STARTUPINFO_dwFlags=
+STARTUPINFO_wShowWindow=
+STARTUPINFO_cbReserved2=
+STARTUPINFO_lpReserved2=cast=LPBYTE
+STARTUPINFO_hStdInput=cast=HANDLE
+STARTUPINFO_hStdOutput=cast=HANDLE
+STARTUPINFO_hStdError=cast=HANDLE
+
org_eclipse_swt_internal_win32_SYSTEMTIME=
SYSTEMTIME_wYear=
SYSTEMTIME_wMonth=
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 368774f7a3..c44f7603b4 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
@@ -423,6 +423,18 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(CloseClipboard)
}
#endif
+#ifndef NO_CloseHandle
+JNIEXPORT jboolean JNICALL OS_NATIVE(CloseHandle)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, CloseHandle_FUNC);
+ rc = (jboolean)CloseHandle((HANDLE)arg0);
+ OS_NATIVE_EXIT(env, that, CloseHandle_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_CloseThemeData
JNIEXPORT jint JNICALL OS_NATIVE(CloseThemeData)
(JNIEnv *env, jclass that, jint arg0)
@@ -1022,6 +1034,44 @@ JNIEXPORT jint JNICALL OS_NATIVE(CreatePopupMenu)
}
#endif
+#ifndef NO_CreateProcessA
+JNIEXPORT jboolean JNICALL OS_NATIVE(CreateProcessA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jboolean arg4, jint arg5, jint arg6, jint arg7, jobject arg8, jobject arg9)
+{
+ STARTUPINFO _arg8, *lparg8=NULL;
+ PROCESS_INFORMATION _arg9, *lparg9=NULL;
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, CreateProcessA_FUNC);
+ if (arg8) if ((lparg8 = getSTARTUPINFOFields(env, arg8, &_arg8)) == NULL) goto fail;
+ if (arg9) if ((lparg9 = getPROCESS_INFORMATIONFields(env, arg9, &_arg9)) == NULL) goto fail;
+ rc = (jboolean)CreateProcessA((LPCSTR)arg0, (LPSTR)arg1, (LPSECURITY_ATTRIBUTES)arg2, (LPSECURITY_ATTRIBUTES)arg3, arg4, arg5, (LPVOID)arg6, (LPSTR)arg7, (LPSTARTUPINFOA)lparg8, (LPPROCESS_INFORMATION)lparg9);
+fail:
+ if (arg9 && lparg9) setPROCESS_INFORMATIONFields(env, arg9, lparg9);
+ if (arg8 && lparg8) setSTARTUPINFOFields(env, arg8, lparg8);
+ OS_NATIVE_EXIT(env, that, CreateProcessA_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_CreateProcessW
+JNIEXPORT jboolean JNICALL OS_NATIVE(CreateProcessW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jboolean arg4, jint arg5, jint arg6, jint arg7, jobject arg8, jobject arg9)
+{
+ STARTUPINFO _arg8, *lparg8=NULL;
+ PROCESS_INFORMATION _arg9, *lparg9=NULL;
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, CreateProcessW_FUNC);
+ if (arg8) if ((lparg8 = getSTARTUPINFOFields(env, arg8, &_arg8)) == NULL) goto fail;
+ if (arg9) if ((lparg9 = getPROCESS_INFORMATIONFields(env, arg9, &_arg9)) == NULL) goto fail;
+ rc = (jboolean)CreateProcessW((LPCWSTR)arg0, (LPWSTR)arg1, (LPSECURITY_ATTRIBUTES)arg2, (LPSECURITY_ATTRIBUTES)arg3, arg4, arg5, (LPVOID)arg6, (LPWSTR)arg7, (LPSTARTUPINFOW)lparg8, (LPPROCESS_INFORMATION)lparg9);
+fail:
+ if (arg9 && lparg9) setPROCESS_INFORMATIONFields(env, arg9, lparg9);
+ if (arg8 && lparg8) setSTARTUPINFOFields(env, arg8, lparg8);
+ OS_NATIVE_EXIT(env, that, CreateProcessW_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_CreateRectRgn
JNIEXPORT jint JNICALL OS_NATIVE(CreateRectRgn)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
@@ -4160,6 +4210,34 @@ fail:
}
#endif
+#ifndef NO_GetStartupInfoA
+JNIEXPORT void JNICALL OS_NATIVE(GetStartupInfoA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ STARTUPINFO _arg0, *lparg0=NULL;
+ OS_NATIVE_ENTER(env, that, GetStartupInfoA_FUNC);
+ if (arg0) if ((lparg0 = getSTARTUPINFOFields(env, arg0, &_arg0)) == NULL) goto fail;
+ GetStartupInfoA((LPSTARTUPINFOA)lparg0);
+fail:
+ if (arg0 && lparg0) setSTARTUPINFOFields(env, arg0, lparg0);
+ OS_NATIVE_EXIT(env, that, GetStartupInfoA_FUNC);
+}
+#endif
+
+#ifndef NO_GetStartupInfoW
+JNIEXPORT void JNICALL OS_NATIVE(GetStartupInfoW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ STARTUPINFO _arg0, *lparg0=NULL;
+ OS_NATIVE_ENTER(env, that, GetStartupInfoW_FUNC);
+ if (arg0) if ((lparg0 = getSTARTUPINFOFields(env, arg0, &_arg0)) == NULL) goto fail;
+ GetStartupInfoW((LPSTARTUPINFOW)lparg0);
+fail:
+ if (arg0 && lparg0) setSTARTUPINFOFields(env, arg0, lparg0);
+ OS_NATIVE_EXIT(env, that, GetStartupInfoW_FUNC);
+}
+#endif
+
#ifndef NO_GetStockObject
JNIEXPORT jint JNICALL OS_NATIVE(GetStockObject)
(JNIEnv *env, jclass that, jint arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
index a214809880..15df48229d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
@@ -153,6 +153,7 @@
#define NO_CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONTA_2
#define NO_CreateFontIndirectA__I
#define NO_CreatePolygonRgn
+#define NO_CreateProcessA
#define NO_CreateStreamOnHGlobal
#define NO_CreateWindowExA
#define NO_DefFrameProcA
@@ -250,6 +251,8 @@
#define NO_GetRandomRgn
#define NO_GetROP2
#define NO_GetSaveFileNameA
+#define NO_GetStartupInfoA
+#define NO_GetStartupInfoW
#define NO_GetSystemDefaultUILanguage
#define NO_GetTextCharset
#define NO_GetTextExtentPoint32A
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 f8bb9ef2b7..b7eeb8b313 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 = 701;
-int OS_nativeFunctionCallCount[701];
+int OS_nativeFunctionCount = 706;
+int OS_nativeFunctionCallCount[706];
char * OS_nativeFunctionNames[] = {
"AbortDoc",
"ActivateActCtx",
@@ -45,6 +45,7 @@ char * OS_nativeFunctionNames[] = {
"ChooseFontW",
"ClientToScreen",
"CloseClipboard",
+ "CloseHandle",
"CloseThemeData",
"CoCreateInstance",
"CombineRgn",
@@ -80,6 +81,8 @@ char * OS_nativeFunctionNames[] = {
"CreatePen",
"CreatePolygonRgn",
"CreatePopupMenu",
+ "CreateProcessA",
+ "CreateProcessW",
"CreateRectRgn",
"CreateSolidBrush",
"CreateStreamOnHGlobal",
@@ -265,6 +268,8 @@ char * OS_nativeFunctionNames[] = {
"GetSaveFileNameA",
"GetSaveFileNameW",
"GetScrollInfo",
+ "GetStartupInfoA",
+ "GetStartupInfoW",
"GetStockObject",
"GetSysColor",
"GetSysColorBrush",
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 fa3f564b0a..1c1bd13a6d 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
@@ -49,6 +49,7 @@ typedef enum {
ChooseFontW_FUNC,
ClientToScreen_FUNC,
CloseClipboard_FUNC,
+ CloseHandle_FUNC,
CloseThemeData_FUNC,
CoCreateInstance_FUNC,
CombineRgn_FUNC,
@@ -84,6 +85,8 @@ typedef enum {
CreatePen_FUNC,
CreatePolygonRgn_FUNC,
CreatePopupMenu_FUNC,
+ CreateProcessA_FUNC,
+ CreateProcessW_FUNC,
CreateRectRgn_FUNC,
CreateSolidBrush_FUNC,
CreateStreamOnHGlobal_FUNC,
@@ -269,6 +272,8 @@ typedef enum {
GetSaveFileNameA_FUNC,
GetSaveFileNameW_FUNC,
GetScrollInfo_FUNC,
+ GetStartupInfoA_FUNC,
+ GetStartupInfoW_FUNC,
GetStockObject_FUNC,
GetSysColor_FUNC,
GetSysColorBrush_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c
index aa1670e2f3..312218d287 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c
@@ -4432,6 +4432,46 @@ void setPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct)
}
#endif
+#ifndef NO_PROCESS_INFORMATION
+typedef struct PROCESS_INFORMATION_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hProcess, hThread, dwProcessId, dwThreadId;
+} PROCESS_INFORMATION_FID_CACHE;
+
+PROCESS_INFORMATION_FID_CACHE PROCESS_INFORMATIONFc;
+
+void cachePROCESS_INFORMATIONFields(JNIEnv *env, jobject lpObject)
+{
+ if (PROCESS_INFORMATIONFc.cached) return;
+ PROCESS_INFORMATIONFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ PROCESS_INFORMATIONFc.hProcess = (*env)->GetFieldID(env, PROCESS_INFORMATIONFc.clazz, "hProcess", "I");
+ PROCESS_INFORMATIONFc.hThread = (*env)->GetFieldID(env, PROCESS_INFORMATIONFc.clazz, "hThread", "I");
+ PROCESS_INFORMATIONFc.dwProcessId = (*env)->GetFieldID(env, PROCESS_INFORMATIONFc.clazz, "dwProcessId", "I");
+ PROCESS_INFORMATIONFc.dwThreadId = (*env)->GetFieldID(env, PROCESS_INFORMATIONFc.clazz, "dwThreadId", "I");
+ PROCESS_INFORMATIONFc.cached = 1;
+}
+
+PROCESS_INFORMATION *getPROCESS_INFORMATIONFields(JNIEnv *env, jobject lpObject, PROCESS_INFORMATION *lpStruct)
+{
+ if (!PROCESS_INFORMATIONFc.cached) cachePROCESS_INFORMATIONFields(env, lpObject);
+ lpStruct->hProcess = (HANDLE)(*env)->GetIntField(env, lpObject, PROCESS_INFORMATIONFc.hProcess);
+ lpStruct->hThread = (HANDLE)(*env)->GetIntField(env, lpObject, PROCESS_INFORMATIONFc.hThread);
+ lpStruct->dwProcessId = (*env)->GetIntField(env, lpObject, PROCESS_INFORMATIONFc.dwProcessId);
+ lpStruct->dwThreadId = (*env)->GetIntField(env, lpObject, PROCESS_INFORMATIONFc.dwThreadId);
+ return lpStruct;
+}
+
+void setPROCESS_INFORMATIONFields(JNIEnv *env, jobject lpObject, PROCESS_INFORMATION *lpStruct)
+{
+ if (!PROCESS_INFORMATIONFc.cached) cachePROCESS_INFORMATIONFields(env, lpObject);
+ (*env)->SetIntField(env, lpObject, PROCESS_INFORMATIONFc.hProcess, (jint)lpStruct->hProcess);
+ (*env)->SetIntField(env, lpObject, PROCESS_INFORMATIONFc.hThread, (jint)lpStruct->hThread);
+ (*env)->SetIntField(env, lpObject, PROCESS_INFORMATIONFc.dwProcessId, (jint)lpStruct->dwProcessId);
+ (*env)->SetIntField(env, lpObject, PROCESS_INFORMATIONFc.dwThreadId, (jint)lpStruct->dwThreadId);
+}
+#endif
+
#ifndef NO_REBARBANDINFO
typedef struct REBARBANDINFO_FID_CACHE {
int cached;
@@ -5347,6 +5387,88 @@ void setSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct)
}
#endif
+#ifndef NO_STARTUPINFO
+typedef struct STARTUPINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cb, lpReserved, lpDesktop, lpTitle, dwX, dwY, dwXSize, dwYSize, dwXCountChars, dwYCountChars, dwFillAttribute, dwFlags, wShowWindow, cbReserved2, lpReserved2, hStdInput, hStdOutput, hStdError;
+} STARTUPINFO_FID_CACHE;
+
+STARTUPINFO_FID_CACHE STARTUPINFOFc;
+
+void cacheSTARTUPINFOFields(JNIEnv *env, jobject lpObject)
+{
+ if (STARTUPINFOFc.cached) return;
+ STARTUPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ STARTUPINFOFc.cb = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "cb", "I");
+ STARTUPINFOFc.lpReserved = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "lpReserved", "I");
+ STARTUPINFOFc.lpDesktop = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "lpDesktop", "I");
+ STARTUPINFOFc.lpTitle = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "lpTitle", "I");
+ STARTUPINFOFc.dwX = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "dwX", "I");
+ STARTUPINFOFc.dwY = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "dwY", "I");
+ STARTUPINFOFc.dwXSize = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "dwXSize", "I");
+ STARTUPINFOFc.dwYSize = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "dwYSize", "I");
+ STARTUPINFOFc.dwXCountChars = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "dwXCountChars", "I");
+ STARTUPINFOFc.dwYCountChars = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "dwYCountChars", "I");
+ STARTUPINFOFc.dwFillAttribute = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "dwFillAttribute", "I");
+ STARTUPINFOFc.dwFlags = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "dwFlags", "I");
+ STARTUPINFOFc.wShowWindow = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "wShowWindow", "S");
+ STARTUPINFOFc.cbReserved2 = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "cbReserved2", "S");
+ STARTUPINFOFc.lpReserved2 = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "lpReserved2", "I");
+ STARTUPINFOFc.hStdInput = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "hStdInput", "I");
+ STARTUPINFOFc.hStdOutput = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "hStdOutput", "I");
+ STARTUPINFOFc.hStdError = (*env)->GetFieldID(env, STARTUPINFOFc.clazz, "hStdError", "I");
+ STARTUPINFOFc.cached = 1;
+}
+
+STARTUPINFO *getSTARTUPINFOFields(JNIEnv *env, jobject lpObject, STARTUPINFO *lpStruct)
+{
+ if (!STARTUPINFOFc.cached) cacheSTARTUPINFOFields(env, lpObject);
+ lpStruct->cb = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.cb);
+ lpStruct->lpReserved = (LPTSTR)(*env)->GetIntField(env, lpObject, STARTUPINFOFc.lpReserved);
+ lpStruct->lpDesktop = (LPTSTR)(*env)->GetIntField(env, lpObject, STARTUPINFOFc.lpDesktop);
+ lpStruct->lpTitle = (LPTSTR)(*env)->GetIntField(env, lpObject, STARTUPINFOFc.lpTitle);
+ lpStruct->dwX = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.dwX);
+ lpStruct->dwY = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.dwY);
+ lpStruct->dwXSize = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.dwXSize);
+ lpStruct->dwYSize = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.dwYSize);
+ lpStruct->dwXCountChars = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.dwXCountChars);
+ lpStruct->dwYCountChars = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.dwYCountChars);
+ lpStruct->dwFillAttribute = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.dwFillAttribute);
+ lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, STARTUPINFOFc.dwFlags);
+ lpStruct->wShowWindow = (*env)->GetShortField(env, lpObject, STARTUPINFOFc.wShowWindow);
+ lpStruct->cbReserved2 = (*env)->GetShortField(env, lpObject, STARTUPINFOFc.cbReserved2);
+ lpStruct->lpReserved2 = (LPBYTE)(*env)->GetIntField(env, lpObject, STARTUPINFOFc.lpReserved2);
+ lpStruct->hStdInput = (HANDLE)(*env)->GetIntField(env, lpObject, STARTUPINFOFc.hStdInput);
+ lpStruct->hStdOutput = (HANDLE)(*env)->GetIntField(env, lpObject, STARTUPINFOFc.hStdOutput);
+ lpStruct->hStdError = (HANDLE)(*env)->GetIntField(env, lpObject, STARTUPINFOFc.hStdError);
+ return lpStruct;
+}
+
+void setSTARTUPINFOFields(JNIEnv *env, jobject lpObject, STARTUPINFO *lpStruct)
+{
+ if (!STARTUPINFOFc.cached) cacheSTARTUPINFOFields(env, lpObject);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.cb, (jint)lpStruct->cb);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.lpReserved, (jint)lpStruct->lpReserved);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.lpDesktop, (jint)lpStruct->lpDesktop);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.lpTitle, (jint)lpStruct->lpTitle);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.dwX, (jint)lpStruct->dwX);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.dwY, (jint)lpStruct->dwY);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.dwXSize, (jint)lpStruct->dwXSize);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.dwYSize, (jint)lpStruct->dwYSize);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.dwXCountChars, (jint)lpStruct->dwXCountChars);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.dwYCountChars, (jint)lpStruct->dwYCountChars);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.dwFillAttribute, (jint)lpStruct->dwFillAttribute);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.dwFlags, (jint)lpStruct->dwFlags);
+ (*env)->SetShortField(env, lpObject, STARTUPINFOFc.wShowWindow, (jshort)lpStruct->wShowWindow);
+ (*env)->SetShortField(env, lpObject, STARTUPINFOFc.cbReserved2, (jshort)lpStruct->cbReserved2);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.lpReserved2, (jint)lpStruct->lpReserved2);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.hStdInput, (jint)lpStruct->hStdInput);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.hStdOutput, (jint)lpStruct->hStdOutput);
+ (*env)->SetIntField(env, lpObject, STARTUPINFOFc.hStdError, (jint)lpStruct->hStdError);
+}
+#endif
+
#ifndef NO_SYSTEMTIME
typedef struct SYSTEMTIME_FID_CACHE {
int cached;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h
index f5762dbc6b..3239abd5e0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h
@@ -995,6 +995,18 @@ void setPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct);
#define PRINTDLG_sizeof() 0
#endif
+#ifndef NO_PROCESS_INFORMATION
+void cachePROCESS_INFORMATIONFields(JNIEnv *env, jobject lpObject);
+PROCESS_INFORMATION *getPROCESS_INFORMATIONFields(JNIEnv *env, jobject lpObject, PROCESS_INFORMATION *lpStruct);
+void setPROCESS_INFORMATIONFields(JNIEnv *env, jobject lpObject, PROCESS_INFORMATION *lpStruct);
+#define PROCESS_INFORMATION_sizeof() sizeof(PROCESS_INFORMATION)
+#else
+#define cachePROCESS_INFORMATIONFields(a,b)
+#define getPROCESS_INFORMATIONFields(a,b,c) NULL
+#define setPROCESS_INFORMATIONFields(a,b,c)
+#define PROCESS_INFORMATION_sizeof() 0
+#endif
+
#ifndef NO_REBARBANDINFO
void cacheREBARBANDINFOFields(JNIEnv *env, jobject lpObject);
REBARBANDINFO *getREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct);
@@ -1199,6 +1211,18 @@ void setSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct);
#define SIZE_sizeof() 0
#endif
+#ifndef NO_STARTUPINFO
+void cacheSTARTUPINFOFields(JNIEnv *env, jobject lpObject);
+STARTUPINFO *getSTARTUPINFOFields(JNIEnv *env, jobject lpObject, STARTUPINFO *lpStruct);
+void setSTARTUPINFOFields(JNIEnv *env, jobject lpObject, STARTUPINFO *lpStruct);
+#define STARTUPINFO_sizeof() sizeof(STARTUPINFO)
+#else
+#define cacheSTARTUPINFOFields(a,b)
+#define getSTARTUPINFOFields(a,b,c) NULL
+#define setSTARTUPINFOFields(a,b,c)
+#define STARTUPINFO_sizeof() 0
+#endif
+
#ifndef NO_SYSTEMTIME
void cacheSYSTEMTIMEFields(JNIEnv *env, jobject lpObject);
SYSTEMTIME *getSYSTEMTIMEFields(JNIEnv *env, jobject lpObject, SYSTEMTIME *lpStruct);
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 fce59bc1a1..a50988190b 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
@@ -1936,6 +1936,11 @@ public static final int CreateFontIndirect (LOGFONT lplf) {
return CreateFontIndirectA ((LOGFONTA)lplf);
}
+public static final boolean CreateProcess (int lpApplicationName, int lpCommandLine, int lpProcessAttributes, int lpThreadAttributes, boolean bInheritHandles, int dwCreationFlags, int lpEnvironment, int lpCurrentDirectory, STARTUPINFO lpStartupInfo, PROCESS_INFORMATION lpProcessInformation) {
+ if (IsUnicode) return CreateProcessW (lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
+ return CreateProcessA (lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
+}
+
public static final int CreateWindowEx (int dwExStyle, TCHAR lpClassName, TCHAR lpWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hWndParent, int hMenu, int hInstance, CREATESTRUCT lpParam) {
if (IsUnicode) {
char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
@@ -2222,6 +2227,14 @@ public static final boolean GetSaveFileName (OPENFILENAME lpofn) {
return GetSaveFileNameA (lpofn);
}
+public static final void GetStartupInfo (STARTUPINFO lpStartupInfo) {
+ if (IsUnicode) {
+ GetStartupInfoW (lpStartupInfo);
+ } else {
+ GetStartupInfoA (lpStartupInfo);
+ }
+}
+
public static final boolean GetTextExtentPoint32 (int hdc, TCHAR lpString, int cbString, SIZE lpSize) {
if (IsUnicode) {
char [] lpString1 = lpString == null ? null : lpString.chars;
@@ -2788,6 +2801,7 @@ public static final native boolean ChooseFontW (CHOOSEFONT chooseFont);
public static final native boolean ChooseFontA (CHOOSEFONT chooseFont);
public static final native boolean ClientToScreen (int hWnd, POINT lpPoint);
public static final native boolean CloseClipboard ();
+public static final native boolean CloseHandle (int hObject);
public static final native int CloseThemeData (int hTheme);
public static final native int CoCreateInstance(byte[] rclsid, int pUnkOuter, int dwClsContext, byte[] riid, int[] ppv);
public static final native int CombineRgn (int hrgnDest, int hrgnSrc1, int hrgnSrc2, int fnCombineMode);
@@ -2823,6 +2837,8 @@ public static final native int CreatePatternBrush (int colorRef);
public static final native int CreatePen (int fnPenStyle, int nWidth, int crColor);
public static final native int CreatePolygonRgn(int[] lppt, int cPoints, int fnPolyFillMode);
public static final native int CreatePopupMenu ();
+public static final native boolean CreateProcessW (int lpApplicationName, int lpCommandLine, int lpProcessAttributes, int lpThreadAttributes, boolean bInheritHandles, int dwCreationFlags, int lpEnvironment, int lpCurrentDirectory, STARTUPINFO lpStartupInfo, PROCESS_INFORMATION lpProcessInformation);
+public static final native boolean CreateProcessA (int lpApplicationName, int lpCommandLine, int lpProcessAttributes, int lpThreadAttributes, boolean bInheritHandles, int dwCreationFlags, int lpEnvironment, int lpCurrentDirectory, STARTUPINFO lpStartupInfo, PROCESS_INFORMATION lpProcessInformation);
public static final native int CreateRectRgn (int left, int top, int right, int bottom);
public static final native int CreateSolidBrush (int colorRef);
public static final native int CreateStreamOnHGlobal(int hGlobal, boolean fDeleteOnRelease, int[] ppstm);
@@ -3013,6 +3029,8 @@ public static final native int GetROP2 (int hdc);
public static final native boolean GetSaveFileNameW (OPENFILENAME lpofn);
public static final native boolean GetSaveFileNameA (OPENFILENAME lpofn);
public static final native boolean GetScrollInfo (int hwnd, int flags, SCROLLINFO info);
+public static final native void GetStartupInfoW (STARTUPINFO lpStartupInfo);
+public static final native void GetStartupInfoA (STARTUPINFO lpStartupInfo);
public static final native int GetStockObject (int fnObject);
public static final native int GetSysColor (int nIndex);
public static final native int GetSysColorBrush (int nIndex);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PROCESS_INFORMATION.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PROCESS_INFORMATION.java
new file mode 100644
index 0000000000..ec2292d27b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PROCESS_INFORMATION.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.win32;
+
+public class PROCESS_INFORMATION {
+ public int hProcess;
+ public int hThread;
+ public int dwProcessId;
+ public int dwThreadId;
+ public static int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/STARTUPINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/STARTUPINFO.java
new file mode 100644
index 0000000000..41a9ede044
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/STARTUPINFO.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.win32;
+
+public class STARTUPINFO {
+ public int cb;
+ public int lpReserved;
+ public int lpDesktop;
+ public int lpTitle;
+ public int dwX;
+ public int dwY;
+ public int dwXSize;
+ public int dwYSize;
+ public int dwXCountChars;
+ public int dwYCountChars;
+ public int dwFillAttribute;
+ public int dwFlags;
+ public short wShowWindow;
+ public short cbReserved2;
+ public int lpReserved2;
+ public int hStdInput;
+ public int hStdOutput;
+ public int hStdError;
+ public static int sizeof = 17 * 4;
+}
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 7d09233383..3182c09a1b 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
@@ -10,14 +10,10 @@
*******************************************************************************/
package org.eclipse.swt.program;
-
-import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-import java.io.IOException;
-
/**
* Instances of this class represent programs and
* their associated file extensions in the operating
@@ -27,6 +23,7 @@ public final class Program {
String name;
String command;
String iconName;
+ static final String [] ARGUMENTS = new String [] {"%1", "%l", "%L"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
* Prevents uninitialized instances from being created outside the package.
@@ -249,27 +246,32 @@ public static boolean launch (String fileName) {
*/
public boolean execute (String fileName) {
if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- boolean quote = true;
+ int index = 0;
String prefix = command, suffix = ""; //$NON-NLS-1$
- int index = command.indexOf ("%1"); //$NON-NLS-1$
- if (index != -1) {
- int count=0;
- int i=index + 2, length = command.length ();
- while (i < length) {
- if (command.charAt (i) == '"') count++;
- i++;
+ while (index < ARGUMENTS.length) {
+ int i = command.indexOf (ARGUMENTS [index]);
+ if (i != -1) {
+ prefix = command.substring (0, i);
+ suffix = command.substring (i + ARGUMENTS [index].length (), command.length ());
+ break;
}
- quote = count % 2 == 0;
- prefix = command.substring (0, index);
- suffix = command.substring (index + 2, length);
- }
- if (quote) fileName = " \"" + fileName + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- try {
- Compatibility.exec(prefix + fileName + suffix);
- } catch (IOException e) {
- return false;
+ index++;
}
- return true;
+ String commandLine = prefix + fileName + suffix;
+ int hHeap = OS.GetProcessHeap ();
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, commandLine, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ int lpCommandLine = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (lpCommandLine, buffer, byteCount);
+ STARTUPINFO lpStartupInfo = new STARTUPINFO ();
+ lpStartupInfo.cb = STARTUPINFO.sizeof;
+ PROCESS_INFORMATION lpProcessInformation = new PROCESS_INFORMATION ();
+ boolean success = OS.CreateProcess (0, lpCommandLine, 0, 0, false, 0, 0, 0, lpStartupInfo, lpProcessInformation);
+ if (lpCommandLine != 0) OS.HeapFree (hHeap, 0, lpCommandLine);
+ if (lpProcessInformation.hProcess != 0) OS.CloseHandle (lpProcessInformation.hProcess);
+ if (lpProcessInformation.hThread != 0) OS.CloseHandle (lpProcessInformation.hThread);
+ return success;
}
/**