Board index » delphi » Help: Using WinExec to execute a DOS program.

Help: Using WinExec to execute a DOS program.

I am using WinExec to execute a DOS program. The DOS program saves
data in a text file that needs to be used by the Windows program. My
problem is that WinExec starts the DOS program and then the windows
program continues execution. How can I suspend the windows programs
execution until the DOS program is finished. I know its possible
because Borlands Resource Compiler does this by using a Microsoft
POPUP utility.

All help will be appreciated.
Thanks
     Dinesh_Hosp...@msn.com

 

Re:Help: Using WinExec to execute a DOS program.


Quote
Dinesh Hospeti wrote:

> I am using WinExec to execute a DOS program. The DOS program saves
> data in a text file that needs to be used by the Windows program. My
> problem is that WinExec starts the DOS program and then the windows
> program continues execution. How can I suspend the windows programs
> execution until the DOS program is finished. I know its possible
> because Borlands Resource Compiler does this by using a Microsoft
> POPUP utility.

> All help will be appreciated.
> Thanks
>      Dinesh_Hosp...@msn.com

I think the Code below will help...

Function ExWinExec(CmdLine:Pchar; CmdShow:Word; Wait:Bool):Word;
   {Extended WindowsExecute}
   {Will Wait for Command To Complete before returning Control}
Var
  AppMessage:Tmsg;
  AppHandle:HWnd;
Begin
  AppHandle := WinExec(CmdLine,Sw_ShowNormal);
  If Wait Then
    While NOT(0=GlobalSize(AppHandle)) Do
      Begin
        IF PeekMessage(AppMessage,0,0,0,pm_REMOVE) Then
          Begin
            TranslateMessage(AppMessage);
            DispatchMessage(AppMessage);
          End;
      End;
End;

Re:Help: Using WinExec to execute a DOS program.


   With D2 you can use WaitForSingleObject
--

           ___                                              ___
           L_|_                                            _|_J
          ( -O>                                            <O- )
       ___//\J  __________________________________________  L/\\___
      //-,\    |                                          |    /,-\\
     || / \\   L   AVONTURE Christophe (c) AVC Software   J___// \ ||
   _ ''/\/ '---J    Christophe.Avont...@is.belgacom.be    L---' \/\'' _
  / \ //\\.    |__________________________________________|    .//\\ / \
 |_/\'/  ||                                                    ||  \'/\_|
      '   ||_       "Postings are personnal, and don't        _||   '
          |__)         reflect Belgacom's opinion"           (__|

               SWAG: http://www.gdsoft.com/swag/swag.html              

                        ftp://ftp.gdsoft.com/swag/

Re:Help: Using WinExec to execute a DOS program.


Quote
Dinesh_Hosp...@msn.com (Dinesh Hospeti) wrote:
>I am using WinExec to execute a DOS program. The DOS program saves
>data in a text file that needs to be used by the Windows program. My
>problem is that WinExec starts the DOS program and then the windows
>program continues execution. How can I suspend the windows programs
>execution until the DOS program is finished. I know its possible
>because Borlands Resource Compiler does this by using a Microsoft
>POPUP utility.

>All help will be appreciated.
>Thanks
>     Dinesh_Hosp...@msn.com

   Really easy with Delphi1 (I don't know how with D2)

   When you launch your DOS program, the WINEXEC function returns to you
a Task handle for this program.  You must use the GetModuleUsage that
returns 0 when your task is closed.

--

           ___                                              ___
           L_|_                                            _|_J
          ( -O>                                            <O- )
       ___//\J  __________________________________________  L/\\___
      //-,\    |                                          |    /,-\\
     || / \\   L   AVONTURE Christophe (c) AVC Software   J___// \ ||
   _ ''/\/ '---J    Christophe.Avont...@is.belgacom.be    L---' \/\'' _
  / \ //\\.    |__________________________________________|    .//\\ / \
 |_/\'/  ||                                                    ||  \'/\_|
      '   ||_       "Postings are personnal, and don't        _||   '
          |__)         reflect Belgacom's opinion"           (__|

               SWAG: http://www.gdsoft.com/swag/swag.html              

                        ftp://ftp.gdsoft.com/swag/

Other Threads