|
-
February 11th, 2005, 01:36 AM
#1
Disconnect internet connection
Hi,
What is the classes or function which used to disconnect internet connection ???
thanks
-
February 11th, 2005, 03:56 AM
#2
Re: Disconnect internet connection
What do U mean by "disconnect internet connection" ?
-
February 11th, 2005, 01:29 PM
#3
Re: Disconnect internet connection
I mean disconnect internet .
-
February 11th, 2005, 01:54 PM
#4
Re: Disconnect internet connection
You can use WinINet ....
Windows Internet Support it
InternetHangUp
can be used to disconnect from the internet.
-
February 11th, 2005, 02:29 PM
#5
Re: Disconnect internet connection
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 ???
-
February 11th, 2005, 02:56 PM
#6
Re: Disconnect internet connection
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);
-
February 13th, 2005, 12:23 AM
#7
Re: Disconnect internet connection
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.
-
February 15th, 2005, 01:31 PM
#8
Re: Disconnect internet connection
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
Usman,
Islamabad, Pakistan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|