请问如何用VC实现WIN2000中net命令的所有功能?有什么相关函数?最好能提供相关源代码。十分感谢!

解决方案 »

  1.   

    net命令有什么功能?可以使用Winsock来实现网络操作功能.
      

  2.   

    用Winsock有点不好,因为这样你必须在需要通信的每台计算机上安装你的程序。可以这样做,就用net命令,在你程序中调用外部函数。

    UINT WinExec(
      LPCSTR lpCmdLine,  // command line
      UINT uCmdShow      // window style
    );HINSTANCE ShellExecute(
        HWND hwnd, 
        LPCTSTR lpOperation,
        LPCTSTR lpFile, 
        LPCTSTR lpParameters, 
        LPCTSTR lpDirectory,
        INT nShowCmd
    );BOOL CreateProcess(
      LPCTSTR lpApplicationName,                 // name of executable module
      LPTSTR lpCommandLine,                      // command line string
      LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
      LPSECURITY_ATTRIBUTES lpThreadAttributes,  // SD
      BOOL bInheritHandles,                      // handle inheritance option
      DWORD dwCreationFlags,                     // creation flags
      LPVOID lpEnvironment,                      // new environment block
      LPCTSTR lpCurrentDirectory,                // current directory name
      LPSTARTUPINFO lpStartupInfo,               // startup information
      LPPROCESS_INFORMATION lpProcessInformation // process information
    );
    他们其中的一个函数就可以了,建议使用前两个
      

  3.   

    你可以重定向cmd(net)命令的输入与输出,这样就可以了。关于重定向msdn你有详细的说明。
      

  4.   

    用CMD重定向,或者用net*系列的函数,但不完全.
      

  5.   

    Agree with the above .
    For simple,
    Suggestion goes to use Rediretion of "cmd.exe".
      

  6.   

    直接执行net.exe虽然简单,但不能接收它的返回信息,请问如何redirection,能否给些详细的例子,谢谢!