Win32OperatingSystem.st
changeset 10364 43968474508b
parent 10352 f2e9bb8906db
child 10365 51b5bd2918c7
equal deleted inserted replaced
10363:5cf689c14989 10364:43968474508b
  5130      html documents, pdf documents etc."
  5130      html documents, pdf documents etc."
  5131 
  5131 
  5132     |result|
  5132     |result|
  5133 
  5133 
  5134     Error
  5134     Error
  5135 	handle:[:ex |
  5135         handle:[:ex |
  5136 	    self halt
  5136             self halt
  5137 	] do:[
  5137         ] do:[
  5138 	    |filename|
  5138             |filename|
  5139 
  5139 
  5140 	    filename := aFilenameOrString asFilename.
  5140             filename := aFilenameOrString asFilename.
  5141 	    result := self
  5141             result := self
  5142 		shellExecute:nil
  5142                 shellExecute:nil
  5143 		lpOperation:'open'
  5143                 lpOperation:'open'
  5144 		lpFile:filename pathName
  5144                 lpFile:filename pathName
  5145 		lpParameters:nil
  5145                 lpParameters:nil
  5146 		lpDirectory:filename directory pathName
  5146                 lpDirectory:filename directory pathName
  5147 		nShowCmd:#SW_SHOWNORMAL.
  5147                 nShowCmd:#SW_SHOWNORMAL.
  5148 	    ^ self.
  5148             ^ self.
  5149 	]
  5149         ]
  5150 
  5150 
  5151     "
  5151     "
  5152      self openDocumentationFilename: 'C:\WINDOWS\Help\clipbrd.chm' asFilename
  5152      self openDocumentationFilename: 'C:\WINDOWS\Help\clipbrd.chm' asFilename
       
  5153      self openDocumentationFilename: Filename currentDirectory
  5153     "
  5154     "
  5154 
  5155 
  5155     "Created: / 04-08-2006 / 18:04:52 / fm"
  5156     "Created: / 04-08-2006 / 18:04:52 / fm"
  5156     "Modified: / 21-09-2006 / 09:41:45 / cg"
  5157     "Modified: / 26-01-2007 / 14:05:44 / cg"
  5157 !
  5158 !
  5158 
  5159 
  5159 openHelpFile: helpFilename inContextID: contextID withOwner: anApplicationModel
  5160 openHelpFile: helpFilename inContextID: contextID withOwner: anApplicationModel
  5160 
  5161 
  5161     |ownerHandle macro|
  5162     |ownerHandle macro|
  7970 
  7971 
  7971     |errorNumber|
  7972     |errorNumber|
  7972 
  7973 
  7973     "
  7974     "
  7974      HINSTANCE ShellExecute(
  7975      HINSTANCE ShellExecute(
  7975 	     HWND hwnd,                      // handle to parent window
  7976              HWND hwnd,                      // handle to parent window
  7976 	     LPCTSTR lpOperation,    // pointer to string that specifies operation to perform
  7977              LPCTSTR lpOperation,    // pointer to string that specifies operation to perform
  7977 	     LPCTSTR lpFile,         // pointer to filename or folder name string
  7978              LPCTSTR lpFile,         // pointer to filename or folder name string
  7978 	     LPCTSTR lpParameters,   // pointer to string that specifies executable-file parameters
  7979              LPCTSTR lpParameters,   // pointer to string that specifies executable-file parameters
  7979 	     LPCTSTR lpDirectory,    // pointer to string that specifies default directory
  7980              LPCTSTR lpDirectory,    // pointer to string that specifies default directory
  7980 	     INT nShowCmd                    // whether file is shown when opened
  7981              INT nShowCmd                    // whether file is shown when opened
  7981      );
  7982      );
  7982     "
  7983     "
  7983 "/  <apicall: long 'ShellExecuteA' (long char* char* char* char* ulong) module:'shell32.dll'>
  7984 "/  <apicall: long 'ShellExecuteA' (long char* char* char* char* ulong) module:'shell32.dll'>
  7984 %{
  7985 %{
  7985 	unsigned long __nShowCmd = 0;
  7986     unsigned long __nShowCmd = 0;
  7986 
  7987 
  7987 	if (__isSmallInteger(nShowCmd)) {
  7988     if (__isSmallInteger(nShowCmd)) {
  7988 	    __nShowCmd = __intVal(nShowCmd);
  7989         __nShowCmd = __intVal(nShowCmd);
  7989 	} else {
  7990     } else {
  7990 	    if (nShowCmd == @symbol(SW_SHOW)) {
  7991         if (nShowCmd == @symbol(SW_SHOW)) {
  7991 		__nShowCmd = SW_SHOW;
  7992             __nShowCmd = SW_SHOW;
  7992 	    }
  7993         } else if (nShowCmd == @symbol(SW_SHOWNORMAL)) {
  7993 	    if (nShowCmd == @symbol(SW_SHOWNORMAL)) {
  7994             __nShowCmd = SW_SHOWNORMAL;
  7994 		__nShowCmd = SW_SHOWNORMAL;
  7995         } else if (nShowCmd == @symbol(SW_SHOWDEFAULT)) {
  7995 	    }
  7996             __nShowCmd = SW_SHOWDEFAULT;
  7996 	    if (nShowCmd == @symbol(SW_SHOWDEFAULT)) {
  7997         } else if (nShowCmd == @symbol(SW_SHOWMAXIMIZED)) {
  7997 		__nShowCmd = SW_SHOWDEFAULT;
  7998             __nShowCmd = SW_SHOWMAXIMIZED;
  7998 	    }
  7999         } else if (nShowCmd == @symbol(SW_SHOWMINIMIZED)) {
  7999 	    if (nShowCmd == @symbol(SW_SHOWMAXIMIZED)) {
  8000             __nShowCmd = SW_SHOWMINIMIZED;
  8000 		__nShowCmd = SW_SHOWMAXIMIZED;
  8001         } else if (nShowCmd == @symbol(SW_SHOWMINNOACTIVE)) {
  8001 	    }
  8002             __nShowCmd = SW_SHOWMINNOACTIVE;
  8002 	    if (nShowCmd == @symbol(SW_SHOWMINIMIZED)) {
  8003         } else if (nShowCmd == @symbol(SW_SHOWNA)) {
  8003 		__nShowCmd = SW_SHOWMINIMIZED;
  8004             __nShowCmd = SW_SHOWNA;
  8004 	    }
  8005         } else if (nShowCmd == @symbol(SW_SHOWNOACTIVATE)) {
  8005 	    if (nShowCmd == @symbol(SW_SHOWMINNOACTIVE)) {
  8006             __nShowCmd = SW_SHOWNOACTIVATE;
  8006 		__nShowCmd = SW_SHOWMINNOACTIVE;
  8007         } else if (nShowCmd == @symbol(SW_MAXIMIZE)) {
  8007 	    }
  8008             __nShowCmd = SW_MAXIMIZE;
  8008 	    if (nShowCmd == @symbol(SW_SHOWNA)) {
  8009         } else if (nShowCmd == @symbol(SW_RESTORE)) {
  8009 		__nShowCmd = SW_SHOWNA;
  8010             __nShowCmd = SW_RESTORE;
  8010 	    }
  8011         } else {
  8011 	    if (nShowCmd == @symbol(SW_SHOWNOACTIVATE)) {
  8012             goto badArgument;
  8012 		__nShowCmd = SW_SHOWNOACTIVATE;
  8013         }
  8013 	    }
  8014     }
  8014 	    if (nShowCmd == @symbol(SW_MAXIMIZE)) {
  8015 
  8015 		__nShowCmd = SW_MAXIMIZE;
  8016     if (((lpOperation == nil) || __isString(lpOperation))
  8016 	    }
  8017      && ((lpFile == nil) || __isString(lpFile))
  8017 	    if (nShowCmd == @symbol(SW_RESTORE)) {
  8018      && ((lpParameters == nil) || __isString(lpParameters))
  8018 		__nShowCmd = SW_RESTORE;
  8019      && ((lpDirectory == nil) || __isString(lpDirectory))
  8019 	    }
  8020     ) {
  8020 	}
  8021         HANDLE __hwnd = 0;
  8021 
  8022         char *__lpOperation   = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
  8022 	if (((lpOperation == nil) || __isString(lpOperation))
  8023         char *__lpFile        = (lpFile != nil) ? __stringVal(lpFile) : NULL;
  8023 	 && ((lpFile == nil) || __isString(lpFile))
  8024         char *__lpParameters  = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
  8024 	 && ((lpParameters == nil) || __isString(lpParameters))
  8025         char *__lpDirectory   = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
  8025 	 && ((lpDirectory == nil) || __isString(lpDirectory))
  8026         long result;
  8026 	) {
  8027 
  8027 	    HANDLE __hwnd = 0;
  8028         if (hwnd != nil) {
  8028 	    char *__lpOperation   = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
  8029             if (__isExternalAddressLike(hwnd)) {
  8029 	    char *__lpFile        = (lpFile != nil) ? __stringVal(lpFile) : NULL;
  8030                 __hwnd = (HANDLE)(__externalAddressVal(hwnd));
  8030 	    char *__lpParameters  = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
  8031             } else
  8031 	    char *__lpDirectory   = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
  8032                 goto badArgument;
  8032 	    long result;
  8033         }
  8033 
  8034         result = ShellExecuteA(__hwnd, __lpOperation, __lpFile, __lpParameters, __lpDirectory, __nShowCmd);
  8034 	    if (hwnd != nil) {
  8035 
  8035 		if (__isExternalAddressLike(hwnd)) {
  8036         /* MS programmers are brain damaged - here's the proof... */
  8036 		    HANDLE __hwnd = (HANDLE)(__externalAddressVal(hwnd));
  8037         if (result > 32) {
  8037 		} else
  8038             RETURN ( self ); /* OK */
  8038 		    goto badArgument;
  8039         }
  8039 	    }
  8040 
  8040 	    result = ShellExecuteA(__hwnd, __lpOperation, __lpFile, __lpParameters, __lpDirectory, __nShowCmd);
  8041         switch (result) {
  8041 
  8042             case 0:
  8042 	    /* MS programmers are brain damaged - here's the proof... */
  8043             case SE_ERR_OOM:
  8043 	    if (result > 32) {
  8044                 result = ERROR_NOT_ENOUGH_MEMORY;
  8044 		RETURN ( self ); /* OK */
  8045                 break;
  8045 	    }
  8046 
  8046 
  8047             case SE_ERR_ACCESSDENIED:
  8047 	    switch (result) {
  8048                 result = ERROR_ACCESS_DENIED;
  8048 		case 0:
  8049                 break;
  8049 		case SE_ERR_OOM:
  8050 
  8050 		    result = ERROR_NOT_ENOUGH_MEMORY;
  8051             case SE_ERR_FNF:
  8051 		    break;
  8052                 result = ERROR_FILE_NOT_FOUND;
  8052 
  8053                 break;
  8053 		case SE_ERR_ACCESSDENIED:
  8054 
  8054 		    result = ERROR_ACCESS_DENIED;
  8055             case SE_ERR_PNF:
  8055 		    break;
  8056                 result = ERROR_PATH_NOT_FOUND;
  8056 
  8057                 break;
  8057 		case SE_ERR_FNF:
  8058 
  8058 		    result = ERROR_FILE_NOT_FOUND;
  8059             default:
  8059 		    break;
  8060                 result = ERROR_INVALID_FUNCTION;
  8060 
  8061                 break;
  8061 		case SE_ERR_PNF:
  8062         }
  8062 		    result = ERROR_PATH_NOT_FOUND;
  8063         errorNumber = __MKUINT( result );
  8063 		    break;
  8064     }
  8064 
       
  8065 		default:
       
  8066 		    result = ERROR_INVALID_FUNCTION;
       
  8067 		    break;
       
  8068 	    }
       
  8069 	    errorNumber = __MKUINT( result );
       
  8070 	}
       
  8071 badArgument: ;
  8065 badArgument: ;
  8072 %}.
  8066 %}.
  8073     errorNumber isNil ifTrue:[
  8067     errorNumber isNil ifTrue:[
  8074 	self error:'invalid argument(s)'.
  8068         self error:'invalid argument(s)'.
  8075     ] ifFalse:[
  8069     ] ifFalse:[
  8076 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
  8070         (OperatingSystem errorHolderForNumber:errorNumber) reportError
  8077     ].
  8071     ].
       
  8072 
       
  8073     "
       
  8074      self openDocumentationFilename: Filename currentDirectory
       
  8075 
       
  8076      self 
       
  8077         shellExecute:nil
       
  8078         lpOperation:'open'
       
  8079         lpFile:(Filename currentDirectory pathName)
       
  8080         lpParameters:nil
       
  8081         lpDirectory:(Filename currentDirectory pathName)
       
  8082         nShowCmd:#SW_SHOWNORMAL
       
  8083 
       
  8084     self 
       
  8085         shellExecute:nil
       
  8086         lpOperation:'explore'
       
  8087         lpFile:(Filename currentDirectory pathName)
       
  8088         lpParameters:nil
       
  8089         lpDirectory:(Filename currentDirectory pathName)
       
  8090         nShowCmd:#SW_SHOWNORMAL
       
  8091     "
       
  8092 
       
  8093     "Modified: / 26-01-2007 / 14:16:38 / cg"
  8078 ! !
  8094 ! !
  8079 
  8095 
  8080 !Win32OperatingSystem class methodsFor:'socket support'!
  8096 !Win32OperatingSystem class methodsFor:'socket support'!
  8081 
  8097 
  8082 socketAccessor
  8098 socketAccessor
 12727 ! !
 12743 ! !
 12728 
 12744 
 12729 !Win32OperatingSystem class methodsFor:'documentation'!
 12745 !Win32OperatingSystem class methodsFor:'documentation'!
 12730 
 12746 
 12731 version
 12747 version
 12732     ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.262 2007-01-24 15:17:49 cg Exp $'
 12748     ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.263 2007-01-26 13:24:15 cg Exp $'
 12733 ! !
 12749 ! !
 12734 
 12750 
 12735 Win32OperatingSystem initialize!
 12751 Win32OperatingSystem initialize!
 12736 Win32OperatingSystem::RegistryEntry initialize!
 12752 Win32OperatingSystem::RegistryEntry initialize!