如何在VC里面运用命令行?
我想在VC里面调用net view命令,并把其执行结果有记事本保存下来,再去读里面的东西,用shellexecute好像不太行,哪位大虾指教一下! 问题点数:40、回复次数:5Top
1 楼newcore(to be or not to be, it's a question.)回复于 2005-06-04 13:10:46 得分 40
system( "net view >>view.txt");
可以吗?
Top
2 楼bohut(●伯虎● )回复于 2005-06-04 13:40:18 得分 0
CString cmdLine="your command";
STARTUPINFO si;
ZeroMemory(&si,sizeof(si));
si.cb=sizeof(si);
PROCESS_INFORMATION pi;
ZeroMemory(&pi,sizeof(pi));
if(CreateProcess(NULL,cmdLine.GetBufferSetLength(MAX_PATH+1),NULL,NULL,FALSE,CREATE_NO_WINDOW,NULL,NULL,&si,&pi))
{
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
WaitForSingleObject(pi.hProcess,INFINITE);Top
3 楼keiy()回复于 2005-06-04 14:01:27 得分 0
还有WinExec,ShellExec都可以
UINT WinExec(
LPCSTR lpCmdLine, // address of command line
UINT uCmdShow // window style for new application
);
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
); Top
4 楼keiy()回复于 2005-06-04 14:09:38 得分 0
没看清,用 newcore(戒烟中&迷茫的寻找第二法门) 的方法可以,否则要重向con的输出:
http://community.csdn.net/Expert/topic/3474/3474250.xml?temp=.9457361Top
5 楼jx_lin()回复于 2005-06-05 12:34:31 得分 0
用WinExec怎么输出重定向?system可以,但是WinExec同一条命令不行Top




