如何在WINDOWS程序调用带参数的DOS程序?(200分)

  • 主题发起人 主题发起人 louew
  • 开始时间 开始时间
L

louew

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在WINDOWS程序中调用带参数的DOS程序,<br>此DOS程序是。EXE的,我想在WINDOWS程序中<br>调用,但DOS程序有一些输出语句在屏幕上,<br>怎么在我的WINDOWS程序中不显示DOS程序的<br>输出,并且我能够得到输出的内容!
 
查查查!!!!, 很多答案<br>ShellExecute<br>WinExec
 
可以用winexec函数。下面是他的具体说明<br>The WinExec function runs the specified application. <br><br>This function is provided for compatibility with earlier versions of Windows. For Win32-based applications, use the CreateProcess function. <br><br>UINT WinExec(<br><br>&nbsp; &nbsp; LPCSTR lpCmdLine, // address of command line <br>&nbsp; &nbsp; UINT uCmdShow // window style for new application <br>&nbsp; &nbsp;); <br>&nbsp;<br><br>Parameters<br><br>lpCmdLine<br><br>Points to a null-terminated character string that contains the command line (filename plus optional parameters) for the application to be executed. If the name of the executable file in the lpCmdLine parameter does not contain a directory path, Windows searches for the executable file in this sequence: <br><br>1. The directory from which the application loaded. <br> 2. The current directory. <br> 3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory. <br> 4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory. <br> 5. The directories listed in the PATH environment variable. <br><br>&nbsp;<br><br>uCmdShow<br><br>Specifies how a Windows-based application window is to be shown and is used to supply the wShowWindow member of the STARTUPINFO parameter to the CreateProcess function. For a list of the acceptable values, see the description of the nCmdShow parameter of the ShowWindow function. For a non-Windows - based application, the PIF file, if any, for the application determines the window state. <br><br>&nbsp;<br><br>Return Values<br><br>If the function succeeds, the return value is greater than 31.<br>If the function fails, the return value is one of the following error values: <br><br>Value Meaning<br>0 The system is out of memory or resources.<br>ERROR_BAD_FORMAT The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).<br>ERROR_FILE_NOT_FOUND The specified file was not found.<br>ERROR_PATH_NOT_FOUND The specified path was not found.<br>&nbsp;<br><br>Remarks<br><br>Win32-based applications should use the CreateProcess function rather than this function. The WinExec function exists in Win32 to provide compatibility with earlier versions of Windows. For more information about how the WinExec function is implemented, see the Remarks section of the LoadModule function.<br>In Win32, the WinExec function returns when the started process calls the GetMessage function or a time-out limit is reached. To avoid waiting for the time out delay, call the GetMessage function as soon as possible in any process started by a call to WinExec.
 
浪费分数,类似的问题有很多——<br>&nbsp; WinExec('command.com /c dir d:/ &gt;d:/dir.dir', SW_HIDE);<br>
 
多人接受答案了。
 
后退
顶部