disbale network from c#

yaniv

Centurion
Joined
Apr 15, 2002
Messages
167
Location
israel
I build an app and i want it to block surfing when a "user" didn't chose, but I can’t find a way to stop the network adapter from c#. I saw and tried a lot of examples and advices from all other the net, 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.

Great thanks
 
Back
Top