Hi,
What is the classes or function which used to disconnect internet connection ???
thanks
Printable View
Hi,
What is the classes or function which used to disconnect internet connection ???
thanks
What do U mean by "disconnect internet connection" ?
I mean disconnect internet .
You can use WinINet ....
Windows Internet Support it
InternetHangUp
can be used to disconnect from the internet.
Thank you for your help
the function is :
DWORD InternetHangUp(
DWORD dwConnection,
DWORD dwReserved
);
can you give me an example explain how to ues it ???
try this .............
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//BEGIN
InternetConnectionState flags = 0;
int nConnection = 0;
bool bInternet = InternetGetConnectedState(ref flags,0);
if (bInternet == false)
{
//Not Connected
if (flags == 0)
{
//Do something to tell the user to install some internet connection
}
int nResult = InternetDial(IntPtr.Zero,"",(int)InternetDialFlags.INTERNET_DIAL_FORCE_PROMPT , ref nConnection , 0);
switch(nResult)
{
case 87://Bad Parameter for InternetDial - Couldn't Connect";
break;
case 668://No Connection for InternetDial - Couldn't Connect";
break;
case 631://User Cancelled Dialup
break;
default://Unknown InternetDial Error
break;
case 0://Connection Succeeded
break;
}
//Do whatever you need to do on the internet (send mail etc)
InternetHangup(nConnection,0);
//DONE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[DllImport("wininet.dll",CharSet=CharSet.Auto)]
static extern bool InternetGetConnectedState(ref InternetConnectionState lpdwFlags, int dwReserved);
[Flags]
enum InternetConnectionState: int
{
INTERNET_CONNECTION_MODEM = 0x1,
INTERNET_CONNECTION_LAN = 0x2,
INTERNET_CONNECTION_PROXY = 0x4,
INTERNET_RAS_INSTALLED = 0x10,
INTERNET_CONNECTION_OFFLINE = 0x20,
INTERNET_CONNECTION_CONFIGURED = 0x40
}
[DllImport("wininet.dll",CharSet=CharSet.Auto)]
static extern int InternetDial(IntPtr hwndParent,[MarshalAs(UnmanagedType.LPStr)] string strConnection,[MarshalAs(UnmanagedType.U4)]int dwFlags,ref int dwConnection,int dwReserved);
[Flags]
enum InternetDialFlags: int
{
INTERNET_DIAL_FORCE_PROMPT =0x2000,
INTERNET_DIAL_SHOW_OFFLINE =0x4000,
INTERNET_DIAL_UNATTENDED =0x8000
}
[DllImport("wininet.dll",CharSet=CharSet.Auto)]
static extern int InternetHangup([MarshalAs(UnmanagedType.U4)] int nConnection,[MarshalAs(UnmanagedType.U4)]int dwReserved);
Thank you ,
I try to write the statements which you give , but there is an error :
"Unable to find an entry point named InternetHangup in DLL wininet.dll".
and reject to disconnect the internet , i donn't understand what is it
thank you for your help.
Hi,
There may be problem with wininet.dll, and i think the problem is of versions...you can search the internet for solving this problem... i hope you will put your self back with GOOGLE.
thanks