1

I build an app i it to block surfing when a user didn't chose, but I can’t find a way to stop the net and work adapter from c#. I saw and tried a lot of examples and advices from stackoverflow, but none worked for me. I tried to disabled the adapter-

public void DisableNetWork(string interfaceName)
{
  SelectQuery wmiQuery = 
      new SelectQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId != NULL");
  ManagementObjectSearcher searchProcedure = new ManagementObjectSearcher(wmiQuery);
  foreach (ManagementObject item in searchProcedure.Get())
  {
    if (((string)item["NetConnectionId"]) == "Local Area Connection")
    {
      try
      {
          item.InvokeMethod("Disable", null);
      }
      catch (Exception ex)
      {
          String s = ex.Message;
      }
    }
  }
}

I tried socket bind to another process, so I can block the browsers, I tried disabling the drivers, but nothing worked so far. Do you any have working working idea for me? If you have, Please check if it working on win7 since I understood that there is a different between XP and 7.

Robert
  • 10,403
  • 14
  • 67
  • 117

1 Answers1

0

Look here -> http://alexintime.dk/tired-of-ipconfig/ It talks about getting the currently used netadapter. then match that to your code

VisualBean
  • 4,908
  • 2
  • 28
  • 57
  • well, first I couldn't download the example. but, does any body have idea on how to do it? stoping the net adapter? – user2812094 Apr 28 '14 at 12:43
  • There is no example to download. You have the correct code for stopping a netadapter - what I'm saying is, maybe "local Area Connection" isn't the correct adapter. – VisualBean Apr 28 '14 at 18:23