Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to play Try Catch
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01676996
Message ID:
01677006
Views:
53
Thank you.

>Doesn't really matter where you put it.
>
>However, if I remember right the ShellExecute API call never actually fails. It'll return an error code, but it will never actually fail by throwing an exception so the Try/Catch is pointless.
>
>You should check the result code from the API call and return that in your function then check the result value.
>
>But even that doesn't tell you much - that only tells you whether ShellExecute was able to parse your command line, not whether the actual invocation worked since the invocation is asynchronous and happens in the background.
>
>+++ Rick ---
>
>>Hi,
>>
>>I have a program/routine in my application which prints a file, using ShellExecute (most of the times the printed file is a PDF). So, the application using Adobe Reader - or whatever is set on the user desktop - to print the document.
>>
>>Sometime there is a problem. If a user does not put in the file name correctly. Or the file has some "odd" characters. So, the printing does not work.
>>
>>I was checking this and found that my program does not have TRY CATCH around ShellExecute. So I am wondering what is a better practice as far as putting the TRY CATCH. Here is how it works:
>>
>>First, the program determines the document to be printed and then has this code:
>>
>>=CallShellExecute( "print", ALLTRIM(tcDocumentName), 0, "", "", tlDoNotShowErrMsg )
>>
>>
>>The function CallShellExecure which is actually print. Example:
>>
>>	DECLARE INTEGER ShellExecute IN "Shell32.dll" ;
>>	    INTEGER hwnd, ;
>>	    STRING lpVerb, ;
>>	    STRING lpFile, ;
>>	    STRING lpParameters, ;
>>	    STRING lpDirectory, ;
>>	    LONG nShowCmd
>>
>>          lnResult =Shellexecute(0, tcCommand, tcFileName, tcParameter,tcDirectory,tnShowCommand)
>>
>>
>>My question is, is it better to wrap the actual ShellExecute() with TRY CATCH or the calling function CallShellExecute()?
>>
>>TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform