Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Example for ShellExecuteEx
Message
From
18/07/2003 08:43:22
 
 
To
18/07/2003 08:35:34
General information
Forum:
Visual Basic
Category:
Windows API functions
Miscellaneous
Thread ID:
00811220
Message ID:
00811448
Views:
13
Whoops! Did it again, sorry, this is a vfp function. You should be able to translate it to VB though. I'm not a VB expert, so your chances of translating it are probably better than mine.

Alan

>Here is the function I use. Since all but the first parameter have defaults, you only really need to call it with the name (and path if necessary) of the file to run.
>
>
>Function ExecShell(tcFileName, tcParams, tcDir, tnShow, tcOperation, tnHWnd)
>LOCAL lnRetVal, lnParams
>
>lnParams = PCount()
>lnRetVal = 0
>
>IF lnParams < 6
>   tnHWnd = 0               && no parent window
>ENDIF
>IF lnParams < 5
>   tcOperation = 'open'     && default command to 'open application'
>ENDIF
>IF lnParams < 4	            && default window to 'normal'
>   tnShow = 5
>ENDIF
>IF lnParams < 3
>   tcDir = ''               && do not chage current directory
>ENDIF
>IF lnParams < 2
>   tcParams = ''            && there are no parameters for the program to run
>ENDIF
>
>IF !EMPTY(tcFileName)   && no file to run? Do nothing.
>   * declare the shellexecute function to launch app
>   DECLARE INTEGER ShellExecute in shell32.dll ;
>      INTEGER hwnd, STRING @lpOperation, STRING @lpFile, STRING @lpParam, ;
>       STRING @lpDir, INTEGER nShowCmd
>
>   DO CASE
>      CASE EMPTY(tcDir) AND EMPTY(tcParams)   && don't change dir and no parameters
>         lnRetVal = ShellExecute(tnHWnd, @tcOperation, @tcFileName, .NULL., .NULL., tnShow)
>
>      CASE EMPTY(tcDir) AND !EMPTY(tcParams)  && don't change dir, but there are parameters
>         lnRetVal = ShellExecute(tnHWnd, @tcOperation, @tcFileName, @tcParams, .NULL., tnShow)
>
>      CASE EMPTY(tcParams) AND !EMPTY(tcDir)   && no parameters, change directory
>         lnRetVal = ShellExecute(tnHWnd, @tcOperation, @tcFileName, .NULL., @tcDir, tnShow)
>
>      OTHERWISE
>         lnRetVal = ShellExecute(tnHWnd, @tcOperation, @tcFileName, @tcParams, @tcDir, tnShow)
>
>   ENDCASE
>ENDIF
>
>RETURN lnRetVal
>
>
>Alan
>
>>Hi!,
>>
>>I'm trying to make a program that executes files, but I can't find a clear example for the API ShellExecuteEx
>>
>>Can somebody send me a clear example?
>>
>>Thanks in advance!!
Previous
Reply
Map
View

Click here to load this message in the networking platform