TIP: Click on subject to list as thread! ANSI
echo: delphi
to: BRYAN SMITH
from: TOMMY USHER
date: 1996-07-07 12:39:00
subject: RUN A DOS BAT FILE.

BS> TU> HOWEVER, if you need to get fancy, and have the calling
BS> TU> program wait, there is a shareware component that will do this.
BS>No need for shareware ...
BS>WinExecAndWait was posted here by Viggo Poulsen on Nov. 23 '95.
BS>---------------------------------------------------------------------
BS>function WinExecAndWait(Path : Pchar; Visibility : word) : word;
BS>var
BS>  InstanceID : THandle;
BS>  Msg : TMSg;
BS>begin
BS>  InstanceID := WinExec(Path,Visibility);
BS>  if InstanceID < 32 then { a value less than 32 indicates an Exec error }
BS>     WinExecAndWait := InstanceID
BS>  else
BS>    repeat
BS>      while PeekMessage(Msg,0,0,0,PM_REMOVE) do begin
BS>        if Msg.Message = WM_QUIT then
BS>           halt(Msg.wParam);
BS>        TranslateMessage(Msg);
BS>        DispatchMessage(Msg);
BS>      end;
BS>    until GetModuleUsage(InstanceID) = 0;
BS>end;
BS>---------------------------------------------------------------------
BS>Viggo should win a prize for the "most frequently-reposted code" :-)
BS>You might want to wrap a shell around it that will accept a Pascal string
BS>as the path argument.  Or you can use the "@1" trick to fake a pChar ...
BS>var s : string ;
BS>s := 'BACKUP.BAT' ; s := s + #0 ;
BS>dec(s[0]) ; { not needed if don't need to re-use s as a pascal string 
later 
BS>WinExecAndWait(@s[1],SW_SHOWMAXIMIZED) ;
BS>MessageDlg('Backup complete, remove disk from A:',mtInformation,[mbOK],0) 

Okay, the question is, does this work for WIN32?  I have used a similar
routine under C/C++ for Window 3.1, but was under the impression that
Windows 95 had eliminated some of the necessary elements of this
routine.
---
 * QMPro 1.52 * "Oh, how absolutely typical of your species!" -- Q
--- WILDMAIL!/WC v4.12 
---------------
* Origin: GC-BBS! (1:226/810.0)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.