--- a/Win32OperatingSystem.st Mon Mar 06 11:05:58 2006 +0100
+++ b/Win32OperatingSystem.st Mon Mar 06 12:43:38 2006 +0100
@@ -6855,42 +6855,79 @@
!Win32OperatingSystem class methodsFor:'shell operations'!
shellExecute:hwnd lpOperation:lpOperation lpFile:lpFile lpParameters:lpParameters lpDirectory:lpDirectory nShowCmd:nShowCmd
- "Opens or prints the specified file, which can be an executable or document file.
- HINSTANCE ShellExecute(
- HWND hwnd, // handle to parent window
- LPCTSTR lpOperation, // pointer to string that specifies operation to perform
- LPCTSTR lpFile, // pointer to filename or folder name string
- LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
- LPCTSTR lpDirectory, // pointer to string that specifies default directory
- INT nShowCmd // whether file is shown when opened
- );"
-"/ <apicall: long 'ShellExecuteA' (long char* char* char* char* ulong) module:'shell32.dll'>
+ "Opens or prints the specified file, which can be an executable or document file."
+
+ |errorNumber|
+
+ "
+ HINSTANCE ShellExecute(
+ HWND hwnd, // handle to parent window
+ LPCTSTR lpOperation, // pointer to string that specifies operation to perform
+ LPCTSTR lpFile, // pointer to filename or folder name string
+ LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
+ LPCTSTR lpDirectory, // pointer to string that specifies default directory
+ INT nShowCmd // whether file is shown when opened
+ );
+ "
+"/ <apicall: long 'ShellExecuteA' (long char* char* char* char* ulong) module:'shell32.dll'>
%{
- if (((lpOperation == nil) || __isString(lpOperation))
- && ((lpFile == nil) || __isString(lpFile))
- && ((lpParameters == nil) || __isString(lpParameters))
- && ((lpDirectory == nil) || __isString(lpDirectory))
- && __isSmallInteger(nShowCmd)) {
- HANDLE __hwnd = 0;
- char *__lpOperation = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
- char *__lpFile = (lpFile != nil) ? __stringVal(lpFile) : NULL;
- char *__lpParameters = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
- char *__lpDirectory = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
- unsigned long __nShowCmd = __intVal(nShowCmd);
- long result;
-
- if (hwnd != nil) {
- if (__isExternalAddressLike(hwnd)) {
- HANDLE __hwnd = (HANDLE)(__externalAddressVal(hwnd));
- } else
- goto badArgument;
- }
- result = ShellExecuteA(__hwnd, __lpOperation, __lpFile, __lpParameters, __lpDirectory, __nShowCmd);
- RETURN (__MKINT(result));
- }
+ if (((lpOperation == nil) || __isString(lpOperation))
+ && ((lpFile == nil) || __isString(lpFile))
+ && ((lpParameters == nil) || __isString(lpParameters))
+ && ((lpDirectory == nil) || __isString(lpDirectory))
+ && __isSmallInteger(nShowCmd)) {
+ HANDLE __hwnd = 0;
+ char *__lpOperation = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
+ char *__lpFile = (lpFile != nil) ? __stringVal(lpFile) : NULL;
+ char *__lpParameters = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
+ char *__lpDirectory = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
+ unsigned long __nShowCmd = __intVal(nShowCmd);
+ long result;
+
+ if (hwnd != nil) {
+ if (__isExternalAddressLike(hwnd)) {
+ HANDLE __hwnd = (HANDLE)(__externalAddressVal(hwnd));
+ } else
+ goto badArgument;
+ }
+ result = ShellExecuteA(__hwnd, __lpOperation, __lpFile, __lpParameters, __lpDirectory, __nShowCmd);
+
+ /* MS programmers are brain damaged - here's the proof... */
+ if (result > 32) {
+ RETURN ( self ); /* OK */
+ }
+
+ switch (result) {
+ case 0:
+ case SE_ERR_OOM:
+ result = ERROR_NOT_ENOUGH_MEMORY;
+ break;
+
+ case SE_ERR_ACCESSDENIED:
+ result = ERROR_ACCESS_DENIED;
+ break;
+
+ case SE_ERR_FNF:
+ result = ERROR_FILE_NOT_FOUND;
+ break;
+
+ case SE_ERR_PNF:
+ result = ERROR_PATH_NOT_FOUND;
+ break;
+
+ default:
+ result = ERROR_INVALID_FUNCTION;
+ break;
+ }
+ errorNumber = __MKUINT( result );
+ }
badArgument: ;
%}.
- self primitiveFailed
+ errorNumber isNil ifTrue:[
+ self error:'invalid argument(s)'.
+ ] ifFalse:[
+ (OperatingSystem errorHolderForNumber:errorNumber) reportError
+ ].
! !
!Win32OperatingSystem class methodsFor:'socket support'!
@@ -11188,7 +11225,7 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.224 2006-03-03 13:29:53 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.225 2006-03-06 11:43:38 cg Exp $'
! !
Win32OperatingSystem initialize!