MS的库:http://msdn.microsoft.com/library/en-us/dnanchor/html/anch_wmi.asp

解决方案 »

  1.   

    获取远程机器的IP,主机名、IP转主机名和主机名转IP很简单IPHostEntry iphost = Dns.Resolve("主机名或IP");iphost.HostName //主机名iphost.AddressList[0].ToString() //IP
      

  2.   

    CSTerry(Terry) 
    说的我也知道,可是我想知道得更详细一点
      

  3.   

    搜索一下以前的贴子吧,很多都是C#写的,以下是vb.net:        Private Sub closepc(ByVal host As String, ByVal username As String, ByVal pws As String, ByVal op As Integer)
            Dim co As ConnectionOptions = New ConnectionOptions
            co.Username = username
            co.Password = pws
            Dim server As String = host.ToLower
            '测试对方是否连通
            Dim isopen As String
            Try
                Dim objPingHost As New pinghost
                objPingHost.TimeOut = 5000               ' --> 5000 msec  Time Out
                objPingHost.DataSize = 32                ' -->   32 bytes Package Size
                objPingHost.Host = server            If objPingHost.Ping() = objPingHost.Options.SUCCESS Then
                    isopen = "yes"
                Else
                    isopen = Nothing
                End If
            Catch ex As Exception
                isopen = Nothing
            End Try
            'MsgBox(server & Chr(10) & username & Chr(10) & pws)
            If Not isopen Is Nothing Then
                If server = System.Net.Dns.GetHostName Then Exit Sub
                Try
                    Dim ms As System.Management.ManagementScope = New System.Management.ManagementScope("\\" + server + "\root\cimv2", co)
                    Dim oq As System.Management.ObjectQuery = New System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem")
                    Dim query As ManagementObjectSearcher = New ManagementObjectSearcher(ms, oq)
                    Dim queryCollection As ManagementObjectCollection = query.Get()
                    For Each mo As ManagementObject In queryCollection
                        Dim ss As String() = {"", ""}
                        Select Case op
                            Case 1  '注销
                                ss(0) = "4"
                                ss(1) = "0"
                            Case 2  '关机
                                ss(0) = "12"
                                ss(1) = "0"
                            Case 3  '重启
                                ss(0) = "6"
                                ss(1) = "0"
                        End Select
                        mo.InvokeMethod("win32ShutDown", ss)
                        Application.DoEvents()
                    Next
                Catch ex As Exception
                    MsgBox(server & Chr(10) & ex.Message)
                End Try
            End If
        End Sub
      

  4.   

    private void buttonReset_Click(object sender, System.EventArgs e)
    {

    UserANDPass temp = new UserANDPass();
    if(temp.ShowDialog(this) != DialogResult.OK)
    {
    return;
    }

    try
    {
    if(temp.textBoxIP.Text != "")
    { ConnectionOptions co = new ConnectionOptions();

    co.Username = temp.textBoxUser.Text;
    co.Password = temp.textBoxPass.Text; string tempPath = "\\\\"+temp.textBoxIP.Text+"\\"+temp.comboBoxPath.Text; System.Management.ManagementScope ms = new ManagementScope(tempPath,co); System.Management.ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_OperatingSystem"); ManagementObjectSearcher query1 = new ManagementObjectSearcher(ms,oq); foreach (ManagementObject mo in query1.Get()) 
    {
    string[] ss ={""};
    mo.InvokeMethod("Reboot",ss);
    }
    }
    else
    {
    System.Management.ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_OperatingSystem"); ManagementObjectSearcher query1 = new ManagementObjectSearcher(oq); foreach (ManagementObject mo in query1.Get()) 
    {
    string[] ss ={""};
    mo.InvokeMethod("Reboot",ss);
    this.richTextBoxShell.Text += temp.textBoxIP.Text + "正在重启!";
    }
    }
    }
    catch(Exception E)
    {
    this.richTextBoxShell.Text += "\n";
    this.richTextBoxShell.Text += E.Message;
    }
    }
      

  5.   

    这是重启的,关机的话调Shutdown方法。把Reboot改成Shutdown就可以了!
      

  6.   

    呵呵,我忘了说了,要求是用SNMP协议来实现~~~~不知道有没有什么不同?