Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I trying to connect and disconnect RELIANCE USB 3G Modem .
but it not working.
so please kindly help me...

C#
var wmiQuery = new SelectQuery("SELECT * FROM Win32_NetworkAdapter " +
                                      "WHERE NetConnectionId != null " +
                                      "AND Manufacturer != 'ZTE CORPORATION' ");
           using (var searcher = new ManagementObjectSearcher(wmiQuery))
           {
               foreach (ManagementObject item in searcher.Get())
               {
                        using (item)
                       {
                               item.InvokeMethod("Enable", null);
                       }

               }
           }
Posted
Updated 31-Oct-12 5:16am
v2
Comments
fjdiewornncalwe 31-Oct-12 11:16am    
So what is the problem. Do you get an exception? (Perhaps you could include that information in your question). What does happen?

1 solution

Try this, and would Enable the adapter:

C#
SelectQuery query = new SelectQuery("Win32_NetworkAdapter", "NetConnectionId != null AND Manufacturer != 'ZTE CORPORATION'");
            ManagementObjectSearcher search = new ManagementObjectSearcher(query);
            foreach (ManagementObject obj in search.Get())
            {

                object[] param = new object[0];
                obj.InvokeMethod("Enable", param);
            }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900