c# - block internet using wininet -
currently using wininet in c# application check internet connection working fine
[dllimport("wininet.dll", setlasterror = true)] public extern static bool internetgetconnectedstate(out int lpdwflags, int dwreserved); [flags] public enum connectionstates { modem = 0x1, lan = 0x2, proxy = 0x4, rasinstalled = 0x10, offline = 0x20, configured = 0x40, }
but problem want block internet not successful how achieve using wininet?
thanks in advance
one way using command prompt in program :
if use command : rasdial /disconnect
disconnect current internet connection internet
for executing command in c# can use code :
string command = "rasdial /disconnect"; system.diagnostics.processstartinfo procstartinfo = new system.diagnostics.processstartinfo("cmd", "/c " + command); procstartinfo.redirectstandardoutput = true; procstartinfo.useshellexecute = false; procstartinfo.createnowindow = true; system.diagnostics.process proc = new system.diagnostics.process(); proc.startinfo = procstartinfo; proc.start();
another solution windows api : rashangup function
Comments
Post a Comment