Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ShellExecute question

Status
Not open for further replies.

diesel6460

Programmer
May 31, 2013
9
US
Hello all. I have a VFP 9 program which calls an EXE to create PDF files and another EXE to zip the numerous PDF files into a single zip file. The EXE's are executed using ShellExecute. This accomplishes the desired result however, each time ShellExecute runs there's a very brief flash of a DOS window which is very unattractive. The syntax is = ShellExecute(0,"OPEN","---.EXE","----params----","",0). The DOS windows that flash on the screen have a header of "c:\windows\system32\cmd.exe". While this action does not effect the ultimate result, it's very distracting to the user considering the program typically makes 500 +/- calls to ShellExecute. Any help will be appreciated.
 
RUN would cause a "DOS" window (it's a shell window) to appear. ShellExecute does not. I don't think it ever does, also in variations using 0 as ShowWindow parameter, which means your EXE is not shown.
the usual usage of Shellexecute is with ShowWindow=1, and it only shows the window of the EXE you call in "normal" state (1 = SW_SHOWNORMAL), not a shell window.

If you see aa shell window, then this could come from something you call from your EXE, like pkzip or arj or whatever compression utility you use that's perhaps used as console application. They also show a "DOS" window (its a console window this time).

Chriss
 
Chris, thanks for your response. You're obviously correct about RUN vs ShellExecute. I've used ShellExecute many times in the past to, among other things, avoid the opening of a "DOS" window. So I think you have correctly identified the problem that either the zip EXE or pdf converter EXE are causing the problem. More likely the PDF converter, based on the number of times the windows flash across the screen. I'll explore that possibility further. Thanks again.
 
I agree. It is clear that the DOS window is being opened by one of the programs that ShellExecute() is executing, not by ShellExecute() itself. So what are those programs - the ones you are using to zip the files or produce the PDFs?

As you no doubt know, there are various ways of producing PDFs from within VFP that don't involve running a DOS program. If the PDFs are coming from a VFP report, you could use XFRX or FoxyPreviewer to create them - in both cases it is possible to do that without any user interaction. Or you can simply "print" the reports to a PDF driver such as CutePDF or PDF Complete.

Similarly for zipping the files.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks for your input Mike. I agree with you & Chris based on the fact that I've used ShellExecute() many times in the past and have never encountered this problem before. I don't think the culprit is the zipping at the end of the program (btw it's WinZip command line). Even if it does behave this way, it's not a big deal because it is called once after all of the PDF's have been produced. The PDF's produced from hundreds of print files produced during program execution seem to be causing the problem. The system is a very old accounting system originally developed in Foxpro 2.5 (DOS based). While it has been modified to run as a VFP 9 app, the many, many report programs still produce PCL files and that's what my program is converting to PDF's using PCL2PDF. PCL2PDF is a command line utility and has an optional parameter for "silent" so as not to display any feedback. However, I'm sure it still opens a "DOS" window which is what the user is seeing when my program is executed. I will check out CutePDF & PDF Complete to see if either is an appropriate replacement for PCL2PDF.
 
It's actually controllable by the last parameter of ShellExecute, whether the window of that application should be shown normal, maximuzed, minimmized or not at all.

diesel6460 said:
btw it's WinZip command line
An exe called by commandline is typically a console application and has a console window.

You can make the call of that via Wscript.Shell:
Code:
loShell = Createobject("wscript.shell")
loShell.Run(command,nShowWindow,.T.)
Where nShowWindow is one of the ShowWindow constants, for example 1 = normal, 0=hide.

Or simply use Window's own Zip capabilities built into shell.application, see faq184-5113

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top