我要要一些关于wmi操作网卡的资料。比如列举网卡  再对各网卡启动和禁止.单单的WMI资料也行。
先谢了!

解决方案 »

  1.   

    Microsoft的網站上有得下的。
    我就是在那下的。
      

  2.   

    msdn??
    好像全是英文的吧。。晕了。。WMI可以实现对网卡的启用和禁用吗?
      

  3.   

    //WMI可以实现对网卡的启用和禁用吗?这个应该可以,不过我没用过WMI实现对网卡的启用和禁用,一定要用WMI吗?
      

  4.   

    ...disable a network connection using WMI?  If you’re using DHCP, you can use the Win32_NetworkAdapterConfiguration and the ReleaseDHCPLease method to release the IP address. If you are not using DHCP, you cannot use WMI to disable a network connection. To reenable the network connection, use objNetCard.RenewDHCPLease. You can also release or renew all DHCP leases using the ReleaseDHCPLeaseAll and RenewDHCPLeaseAll methods.strComputer = "."
    Set objWMIService = GetObject( _
        "winmgmts:\\" & strComputer & "\root\cimv2")
    Set colNetCards = objWMIService.ExecQuery _
        ("Select * From Win32_NetworkAdapterConfiguration " _
            & "Where IPEnabled = True")
    For Each objNetCard in colNetCards
        objNetCard.ReleaseDHCPLease()
    Next
      

  5.   

    ...disable a network connection using WMI?  If you’re using DHCP, you can use the Win32_NetworkAdapterConfiguration and the ReleaseDHCPLease method to release the IP address. If you are not using DHCP, you cannot use WMI to disable a network connection. To reenable the network connection, use objNetCard.RenewDHCPLease. You can also release or renew all DHCP leases using the ReleaseDHCPLeaseAll and RenewDHCPLeaseAll methods.strComputer = "."
    Set objWMIService = GetObject( _
        "winmgmts:\\" & strComputer & "\root\cimv2")
    Set colNetCards = objWMIService.ExecQuery _
        ("Select * From Win32_NetworkAdapterConfiguration " _
            & "Where IPEnabled = True")
    For Each objNetCard in colNetCards
        objNetCard.ReleaseDHCPLease()
    Next
      

  6.   

    //再对各网卡启动和禁止刚刚看了MSDN,这个不行
      

  7.   

    我现在就是要实现先列举  网卡设备再用各网卡实现启动和禁我不使用dhcp的,那还有什么方法吗 ??急死了
      

  8.   

    找到一段delphi 的网卡启用禁用代码
    但是一点也看不懂 
    谁能帮帮忙
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,Shell32_TLB, StdCtrls, Menus;type
      TForm1 = class(TForm)
        Button1: TButton;
        ComboBox1: TComboBox;
        Button2: TButton;
        Button3: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;  
    var
      Form1: TForm1;implementation{$R *.dfm}
    {++Routine Description:    取本机所有网络链接列表Arguments:    OUT list - 取得的网络链接列表Return Value:    BOOLEAN - 执行是否成功--}function GetNetLinkList(var list:TStrings):BOOLEAN;
    var
        Shell:TShell;
        ControlPanel:Folder;
        Item:FolderItem;
        i:integer;
    begin    Result:= FALSE;
        if list = nil then
            exit;    Shell:=TShell.Create(Application);
        if Shell = nil then
            exit;    ControlPanel:=Shell.NameSpace(ssfCONTROLS);
        for i:=0 to ControlPanel.items.Count -1 do
        begin
            Item:=ControlPanel.items.Item(i);
            if (Item.Name = '网络和拨号连接') then  //如果是英文的windows则Name也需是英文的
            begin
                ControlPanel:=Folder(Item.GetFolder);
                break;
            end;
        end;    for i:=0 to ControlPanel.items.count-1 do
        begin
            Item:= ControlPanel.items.Item(i);
            List.Add(Item.Name);
        end;
        FreeAndNil(shell);    Result:= TRUE;
    end;
    {++Routine Description:    执行 本地网络链接 的菜单命令(包括禁用、启用)Arguments:    IN AdapterName - 网络链接名称
        IN MenuName - 菜单名称Return Value:    BOOLEAN - 执行是否成功--}function ExcNetLinkMenu(const AdapterName,MenuName:String):BOOLEAN;
    var
        Shell:TShell;
        ControlPanel:Folder;
        Item:FolderItem;
        i,j:integer;
        Verb:FolderItemVerb;
    begin    Result:= FALSE;    Shell:=TShell.Create(Application);
        if Shell = nil then
            exit;    ControlPanel:=Shell.NameSpace(ssfCONTROLS);
        for i:=0 to ControlPanel.items.Count -1 do
        begin
            Item:=ControlPanel.items.Item(i);
            if (Item.Name = '网络和拨号连接') then  //如果是英文的windows则Name也需是英文的
            begin
                ControlPanel:=Folder(Item.GetFolder);
                break;
            end;
        end;    for i:=0 to ControlPanel.items.count-1 do
        begin
            Item:=ControlPanel.items.Item(i);
            if (Item.Name = AdapterName) then  //如果是英文的windows则Name也需是英文的
            begin
                for j:=0 to Item.Verbs.Count -1 do
                begin
                    Verb:=Item.Verbs.Item(j);
                    if (Verb.Name = MenuName) then
                    begin
                        Verb.DoIt ;
                        Result:=TRUE;
                        break;
                    end;
                end;
                break;
            end;
        end;    FreeAndNil(shell);end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
        list:TStrings;
    begin
        List:=TStringList.Create ;
        GetNetLinkList(List);
        ComboBox1.Items:=List;
        FreeAndNil(List);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
        ExcNetLinkMenu('本地连接 2','启用(&A)');
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
        ExcNetLinkMenu('本地连接 2','禁用(&B)');
    end;end. 
      

  9.   

    调用shell32.dll
    但是一点也不知道。。
    哪里有资料。。唉 死定了(******************************************************************************
    *   CopyRight (c) By 姚佩云 2004
    *   All Right Reserved
    *   Email : [email protected] www.jynx.com.cn
    *   Date    :
    *       New Develop   : 2004-4-8
    *   Description :
    *       这是一个禁用、启用网卡的例子,实际上通过shell可以控制整个界面,参考的网上资料
    *       需要先引用 Microsoft Shell Controls And Automation(Shell32.dll)对应delphi声明 Shell32_TLB.pas
    *   Export  :
    *       GetNetLinkList
    *       ExcNetLinkMenu
    *   首发大富翁(www.delphibbs.com)blog,转载请保留
      

  10.   

    WMI很少有人知道的,
    帮你顶