<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>

<META content="MSHTML 6.00.2900.2627" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=821235918-11052005>My 
guess is a timing&nbsp;issue caused by lesser&nbsp;horsepower on the other PC's- 
I think the default for shellexecute is to spawn a new process and continue in 
the mainline, which on some pcs executes the application.terminate before it has 
got to bringing up the shellexecute.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=821235918-11052005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=821235918-11052005>I 
found a couple of references to this and different ways around 
it...</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=821235918-11052005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=821235918-11052005><A 
href="http://delphi.about.com/od/windowsshellapi/l/aa082499.htm">http://delphi.about.com/od/windowsshellapi/l/aa082499.htm</A></SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><A 
href="http://www.latiumsoftware.com/en/delphi/00003.php">http://www.latiumsoftware.com/en/delphi/00003.php</A></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=821235918-11052005><FONT face=Arial color=#0000ff size=2>and 
courtesy of Google desktop search it has been referred to in DUG before - see 
below</FONT></SPAN></DIV>
<DIV><SPAN class=821235918-11052005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=821235918-11052005><FONT face=Arial color=#0000ff size=2>You 
could always do something really simple like:</FONT></SPAN></DIV>
<DIV><SPAN class=821235918-11052005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=821235918-11052005>
<DIV><FONT face=Arial color=#0000ff 
size=2>ShellExecute(0,'open',pChar(OpenDialog.Filename),'/SILENT 
/NOCANCEL',nil,SW_NORMAL);</FONT></DIV>
<DIV><SPAN class=821235918-11052005></SPAN><FONT face=Arial><FONT 
color=#0000ff><FONT size=2><SPAN class=821235918-11052005>if SlowPC = true then 
</SPAN>S<SPAN class=821235918-11052005>howMessage('Click OK when the install has 
finished');</SPAN><BR>Application.Terminate;<BR></FONT></FONT></FONT></DIV></SPAN></DIV>
<DIV><SPAN class=821235918-11052005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=821235918-11052005><FONT face=Arial color=#0000ff size=2>From 
DUG</FONT></SPAN></DIV>
<DIV><SPAN class=821235918-11052005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=821235918-11052005><FONT size=2>If you are starting acrobat 
from your application then you could try starting it using the code below that 
will not return <SPAN class=hl>until</SPAN> the program you started has <SPAN 
class=hl>finished</SPAN>. I am not sure of the origion of the code but it works 
for me where I call pkunzip and don't want to carry on <SPAN 
class=hl>until</SPAN> it is 
complete.<BR><BR>Warren.S<BR><BR><BR><BR><BR><BR>function 
WinExecAndWait(CmdLine,DefaultDir: string; showCmd: Word; Yield: Boolean): 
Integer;<BR>// Spawn Exe and <SPAN class=hl>wait</SPAN> <SPAN 
class=hl>until</SPAN> <SPAN class=hl>finished</SPAN><BR>//if Yield then 
ProcessMessages<BR>var<BR>StartUpInfo: TStartupInfo;<BR>ProcessInfo: 
TProcessInformation;<BR>ProcessStatus: DWORD;<BR>lpExitCode: DWORD; // address 
to receive termination status<BR>begin<BR>Result := -1;<BR>Fillchar(StartUpInfo, 
SizeOf(StartUpInfo), #0);<BR>with StartUpInfo do begin<BR>cb := 
SizeOf(StartUpInfo);<BR>wShowWindow := 
showCmd;<BR>end;<BR>UniqueString(CmdLine);<BR>if not (CreateProcess(nil, 
PChar(CmdLine), nil, nil, False, //Spawn<BR>CREATE_DEFAULT_ERROR_MODE, nil, 
PChar(DefaultDir),<BR>StartUpInfo, ProcessInfo))<BR>then Exit;<BR>with 
ProcessInfo do begin //<SPAN class=hl>wait</SPAN> <SPAN class=hl>until</SPAN> 
process <SPAN class=hl>finished</SPAN><BR>WaitForInputIdle(hProcess, 
INFINITE);<BR>CloseHandle(hThread);<BR>while GetExitCodeProcess(hProcess, 
ProcessStatus) and<BR>(ProcessStatus = STILL_ACTIVE) do<BR>if Yield then 
Application.ProcessMessages;<BR>GetExitCodeProcess(hProcess, 
lpExitCode);<BR>result := 
lpExitCode;<BR>CloseHandle(hProcess);<BR>end;<BR>end;<BR><BR><BR><BR>-----Original 
Message-----<BR>From: </FONT><A 
href="mailto:Dave.Jollie@nz.towerlimited.com"><FONT color=#0000cc 
size=2>Dave.Jollie@nz.towerlimited.com</FONT></A><FONT size=2> [mailto:</FONT><A 
href="mailto:Dave.Jollie@nz.towerlimited.com"><FONT color=#0000cc 
size=2>Dave.Jollie@nz.towerlimited.com</FONT></A><FONT size=2>]<BR>Sent: Monday, 
15 September 2003 08:16 a.m.<BR>To: Multiple recipients of list 
delphi<BR>Subject: [DUG]: How do I examine the printer 
queue?<BR><BR>Hi<BR><BR><BR><BR>I have an app which uses a <SPAN 
class=hl>ShellExecute</SPAN> to print a whole lot of PDFs one after the other. 
It first assigns a different printer, prints the pdfs and then assigns back to 
the default printer. It is a scheduled job. The problem is that it is printing 
some of the pdfs on the correct printer, and some on the default printer. What I 
think is happening, is that Acrobat is still busy spooling the pdfs, when I 
re-assign the default printer and close my app. Since the printer has been 
re-assigned to the default, the remaining pdfs that are still in the process of 
being spooled, end up on the default printer. (My re-assign to default printer 
has a sendmessage which broadcasts the printer change to all 
apps).<BR><BR><BR><BR>I'm not that familiar with the printer unit. I want to 
either pause my app from reassigning the default printer and closing, <SPAN 
class=hl>until</SPAN> all the files have been spooled, or <SPAN 
class=hl>until</SPAN> the spooler is empty. So I either need to see if Acrobat 
is still open and <SPAN class=hl>wait</SPAN>, or see if the spool queue still 
has entries and <SPAN class=hl>wait</SPAN>.<BR><BR><BR><BR>Any suggestions on 
how to do either of these?</FONT><BR><BR><BR></SPAN></DIV>
<DIV class=Section1>
<P class=MsoAutoSig align=left>John Bird</P>
<P class=MsoAutoSig><FONT face=Arial size=2>email </FONT><A 
href="mailto:johnkbird@paradise.net.nz">johnkbird@paradise.net.nz</A></P>
<P class=MsoAutoSig><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</P>
<P class=MsoAutoSig><?xml:namespace prefix = o ns = 
"urn:schemas-microsoft-com:office:office" 
/><o:p><!--StartFragment -->&nbsp;</o:p></P></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV></DIV>
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT 
  face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> 
  delphi-bounces@ns3.123.co.nz [mailto:delphi-bounces@ns3.123.co.nz] <B>On 
  Behalf Of </B>Ross Levis<BR><B>Sent:</B> Thursday, 12 May 2005 12:05 
  a.m.<BR><B>To:</B> NZ Borland Developers Group - Delphi 
  List<BR><B>Subject:</B> [DUG] ShellExecute problem<BR><BR></FONT></DIV>
  <DIV><FONT face=Arial size=2>I've got a strange problem&nbsp;at 
  some&nbsp;clients where ShellExecute fails to run.&nbsp; In this particular 
  curcumstance, the ShellExecute is being run just before my program terminates, 
  but I don't see why that has anything to do with it.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>This is used to update the program by running a 
  silent install, which then re-loads the program afterwards.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>This works fine here 100% of the time on my fast 
  development PC, though I have seen the problem on a slow test PC once or 
  twice.&nbsp; The other clients affected also have slow PC's.&nbsp; The program 
  terminates but the install doesn't run.&nbsp; All are Windows XP.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Here is the exact code.</FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial 
  size=2>ShellExecute(0,'open',pChar(OpenDialog.Filename),'/SILENT 
  /NOCANCEL',nil,SW_NORMAL);<BR>Application.Terminate;<BR></FONT></DIV>
  <DIV><FONT face=Arial size=2><FONT color=#000000>The install process is 
  visible on the screen when it runs, yet it doesn't show at all on these other 
  PC's, as if the ShellExecute was totally ignored.</FONT></FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV>
  <DIV><FONT face=Arial size=2>Does anyone&nbsp;have any clues?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></DIV>
  <DIV><FONT face=Arial size=2><FONT color=#000000>Regards,</FONT></FONT></DIV>
  <DIV><FONT face=Arial size=2><FONT color=#000000>Ross.</FONT></FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>