我想在VC里面调用net view命令,并把其执行结果有记事本保存下来,再去读里面的东西,用shellexecute好像不太行,哪位大虾指教一下!

解决方案 »

  1.   


    system( "net view >>view.txt");可以吗?
      

  2.   

    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);
      

  3.   

    还有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
    );
      

  4.   

    没看清,用 newcore(戒烟中&迷茫的寻找第二法门) 的方法可以,否则要重向con的输出:
    http://community.csdn.net/Expert/topic/3474/3474250.xml?temp=.9457361
      

  5.   

    用WinExec怎么输出重定向?system可以,但是WinExec同一条命令不行