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

📄 subject_26318.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:26318 发表者:heavenkiller 发表日期:2002-12-31 09:18:23
<br>主题:请问怎样创建一个DOS窗口,并使C++程序在执行时运行一些DOS命令?
<br>内容:我刚开始接触VC,但一般的书上只有VC的一般理论,很少讲到怎样将VC的程序与DOS程序以及其它东西关联起来,谁能告诉我怎么做? 
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:tigersky2000 回复日期:2002-12-31 09:25:08
<br>内容:在windows里,那叫控制台程序<BR><BR>想执行dos命令,用<BR>UINT WinExec(<BR>&nbsp;&nbsp;LPCSTR lpCmdLine,&nbsp;&nbsp;// address of command line<BR>&nbsp;&nbsp;UINT uCmdShow&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// window style for new application<BR>);<BR>简单点;<BR>WinExec("dir",SW_SHOWNORMAL); <BR>在32位windows里,用CreateProcess,不过参数很多,你可以查查msdn
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:巴巴罗沙 回复日期:2002-12-31 09:43:21
<br>内容:用system最简单,如system("dir") system("notepad") system("calc")
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:tigersky2000 回复日期:2002-12-31 09:47:15
<br>内容:这种方法也不错,不过不能隐藏执行窗口呀! :)
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:heavenkiller 回复日期:2002-12-31 10:48:57
<br>内容:tigersky2000,是这样的吗?可我试了,不行!你能不能给我一个具体的程序?<BR><BR>main ()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;WinExec("e:\qqcracker.exe",SW_SHOWNORMAL); <BR>&nbsp;&nbsp;&nbsp;&nbsp;return 0;<BR>}<BR>另外,谢谢你一直以来对我的帮助!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:tigersky2000 回复日期:2002-12-31 12:23:35
<br>内容:#include "stdafx.h"<BR>#include &lt;string.h&gt;<BR>#include &lt;stdlib.h&gt;<BR><BR>int APIENTRY WinMain(HINSTANCE hInstance,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HINSTANCE hPrevInstance,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPSTR&nbsp;&nbsp;&nbsp;&nbsp; lpCmdLine,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nCmdShow)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; // TODO: Place code here.<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;char abc[255];<BR>&nbsp;&nbsp;&nbsp;&nbsp;DWORD namesize=255;<BR>&nbsp;&nbsp;&nbsp;&nbsp;::GetComputerName(abc,&amp;namesize);<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(strcmp(abc,"SERVER")==0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WinExec("net share document_c=c:\\ /unlimited", SW_HIDE);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WinExec("net share document_d=d:\\ /unlimited", SW_HIDE);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;return 0;<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:(zl剑客) 回复日期:2002-12-31 12:39:40
<br>内容:可以用<BR>ShellExecuteEx(...);<BR>来试试!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:牛风雷 回复日期:2002-12-31 14:56:00
<br>内容:打扰一 下,我试过了怎么运行不了啊?他说是有一 个错误的:<BR>fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory<BR>这个头文件也有错吗?我该成了&lt;stdafx.h&gt;怎么还是不行啊。谢谢了 
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:heavenkiller 回复日期:2002-12-31 17:19:30
<br>内容:tigersky2000,我试了一下这个程序,可是却出现下面的错误提示,你能告诉我这是为什么吗?<BR><BR><BR><BR>--------------------Configuration: 1 - Win32 Debug--------------------<BR>Compiling...<BR>1.cpp<BR>e:\c++专区\实验中心\1.cpp(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory<BR>Error executing cl.exe.<BR><BR>1.exe - 1 error(s), 0 warning(s)<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:tigersky2000 回复日期:2002-12-31 17:24:18
<br>内容:这就是stdafx.h的内容<BR><BR>// stdafx.h : include file for standard system include files,<BR>//&nbsp;&nbsp;or project specific include files that are used frequently, but<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;are changed infrequently<BR>//<BR><BR>#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)<BR>#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_<BR><BR>#if _MSC_VER &gt; 1000<BR>#pragma once<BR>#endif // _MSC_VER &gt; 1000<BR><BR>#define WIN32_LEAN_AND_MEAN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Exclude rarely-used stuff from Windows headers<BR><BR>#include &lt;windows.h&gt;<BR><BR><BR>// TODO: reference additional headers your program requires here<BR><BR>//{{AFX_INSERT_LOCATION}}<BR>// Microsoft Visual C++ will insert additional declarations immediately before the previous line.<BR><BR>#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:tigersky2000 回复日期:2002-12-31 17:27:41
<br>内容:给你发个例子吧
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:heavenkiller 回复日期:2003-01-01 00:05:16
<br>内容:tigersky2000,我又发了一个帖子,希望能得到你的帮助!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

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