⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wpw_wapi_dos_95.html

📁 VC programing
💻 HTML
字号:
<HTML>

<HR><A NAME=WINAPI_MISC_CALL_DOS_APP>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: How to spawn a dos application?</H4><PRE>
>I'm having a problem trying to use the spawnxx functions. I'm using
>the Borland Turbo C++ 3.0 compiler. I've written an ObjectWindows
>program that needs to call a DOS program. 
[Snip]

Use WinExec instead of spawn. As I suppose your next question will
be "how can I wait for the WinExeced program completion" :-), I suggest
that you get the TERMWAIT program on ftp.microsoft.com in the
/softlib/mslfiles directory.

David


----- Standards are great. Everyone should have one ! (Charles Moore) -----
David Brabant,             | E-mail: David.Brabant@csl.sni.be
Siemens Nixdorf,           | X-400:  C=BE;A=RTT;P=SCN;O=SNI;OU1=LGG1;OU2=S1
Centre Software de Lihge,  |         S=BRABANT;G=DAVID
2, rue des Fories,         | URLs:   www.sni.de       www.csl.sni.be/~david
4020 Lihge (BELGIUM)       | Phone:  +32 41 201 609     FAX: +32 41 201 642
</PRE>


<HR><A NAME=WINAPI_MISC_END_DOS_APP>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Finding End of DOS app</H4><PRE>

On 13 Jun 1995 09:05:23 GMT, Mikolaj Rydzewski (rydzew@student.uci.agh.edu.pl) (<3rjkcj$4o2@galaxy.uci.agh.edu.pl>) wrote:
:>Angus-H.W. Chan (R22995@paccvm.corp.mot.com) wrote:
:>:       I would like to ask if I can execute the PIF(or the DOS program)
:>: completely before the application goes on, by WinExec() or other means.
:>: I shall be very grateful if anyone can give me a hand.

:>I don't know if this solution will work, but you may try ;)
:>WinExec (or ShellExecute) returns task's id. There're several functions to
:>determine whether given task or handle is valid. And you may wait in a loop
:>until the DOS app stops: while (IsValidTask(task));

:>--

  It won't, since your code is executing an endless loop and the DOS app
will not have a chance to get the processor and execute to it's end.
  The solution I found is to set a timer when launching the DOS app,
and sample the instance handle when processing WM_TIMER messages.
  When the WM_TIMER processing code finds that the DOS app is done, it
can signal the rest of your application (don't forget to killTimer,
which is what I did :( ).
  Notice this solution has the disadvantage that the user can try to launch
another DOS app before the first one is done, so it's probably best to test
if one DOS app is alive before launching any DOS app.

  I found it easiest to launce with ShellExecute and to test the life of
the DOS app with GetModuleUsage (be zero when the app is done).

--
Dan Pelleg, 
Technion -- Israel Institute of Technology
Haifa, Israel
<HR>
Why not use NotifyRegisterCallback from toolhelp.dll. It will call a 
specific function when the application terminates and I believe it 
works just as well with DOS or Windows apps.

I got it working with help from Borland Tech support from the termwait 
example supplied by microsoft.
|-------------------------------------------------------------------| 
|Dave Allen    EMail dave@drax.demon.co.uk                          |     
|-------------------------------------------------------------------|
</PRE> 

</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -