Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than wininet, prefix the name with the module name and a period.
InternetGetConnectedState (wininet)
.
C# Signature:
/// <summary>
/// Retrieves the connected state of the local system.
/// <para>
/// For more information go to
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa384702%28v=vs.85%29.aspx
/// </para>
/// </summary>
/// <param name="description">
/// C++ ( lpdwFlags [out]. Type: LPDWORD )<br />Pointer to a variable that receives the connection description. This
/// parameter may return a valid flag even when the function returns FALSE. This parameter can be one or more of the
/// following values.
/// <list type="table">
/// <listheader>
/// <term>Internet Connection State Possible Flags</term>
/// </listheader>
/// <item>
/// <term>INTERNET_CONNECTION_CONFIGURED (0x40)</term>
/// <description>
/// Local system has a valid connection to the Internet, but it might or might not be currently
/// connected.
/// </description>
/// </item>
/// <item>
/// <term>INTERNET_CONNECTION_LAN (0x02)</term>
/// <description>Local system uses a local area network to connect to the Internet.</description>
/// </item>
/// <item>
/// <term>INTERNET_CONNECTION_MODEM (0x01)</term>
/// <description>Local system uses a modem to connect to the Internet.</description>
/// </item>
/// <item>
/// <term>INTERNET_CONNECTION_MODEM_BUSY (0x08)</term>
/// <description>No longer used.</description>
/// </item>
/// <item>
/// <term>INTERNET_CONNECTION_OFFLINE (0x20)</term>
/// <description>Local system is in offline mode.</description>
/// </item>
/// <item>
/// <term>INTERNET_CONNECTION_PROXY (0x04)</term>
/// <description>Local system uses a proxy server to connect to the Internet.</description>
/// </item>
/// <item>
/// <term>INTERNET_RAS_INSTALLED (0x10)</term>
/// <description>Local system has RAS installed.</description>
/// </item>
/// </list>
/// </param>
/// <param name="reservedValue">C++ ( dwReserved [in].Type: )<br />This parameter is reserved and must be 0.</param>
/// <returns>
/// <c>true</c> if there is an active modem or a LAN Internet connection, <c>false</c> if there is no Internet
/// connection, or if all possible Internet connections are not currently active.
/// </returns>
/// <remarks>
/// A return value of TRUE from InternetGetConnectedState indicates that at least one connection to the Internet is
/// available. It does not guarantee that a connection to a specific host can be established. Applications should
/// always check for errors returned from API calls that connect to a server. InternetCheckConnection can be called to
/// determine if a connection to a specific destination can be established.
/// <br />A return value of TRUE indicates that either the modem connection is active, or a LAN connection is active
/// and a proxy is properly configured for the LAN.A return value of FALSE indicates that neither the modem nor the LAN
/// is connected.If FALSE is returned, the INTERNET_CONNECTION_CONFIGURED flag may be set to indicate that autodial is
/// configured to "always dial" but is not currently active.If autodial is not configured, the function returns FALSE.
/// <br />Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the
/// constructors and destructors of global objects.
/// <br />Note WinINet does not support server implementations. In addition, it should not be used from a service. For
/// server implementations or services use Microsoft Windows HTTP Services (WinHTTP).
/// </remarks>
[DllImport("wininet.dll", SetLastError=true)]
extern static bool InternetGetConnectedState(out int lpdwFlags, int dwReserved);
using System;
using System.Runtime.InteropServices;
namespace ConsoleApplication2
{
internal class Program
{
[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetGetConnectedState(out int lpdwFlags, int dwReserved);
Function Get_InternetConnectedState(ByRef p_lngFlags As Long, Optional ByRef p_return_str As String = "") As Boolean
Dim lngFlags As Long
lngFlags = 0
Get_InternetConnectedState = False
If InternetGetConnectedState(lngFlags, 0) Then
'connected.
If lngFlags And ConnectionStates.LAN Then
'LAN connection.
p_return_str = "LAN connection."
ElseIf lngFlags And ConnectionStates.Modem Then
'Modem connection.
p_return_str = "Modem connection."
ElseIf lngFlags And ConnectionStates.Proxy Then
'Proxy connection.
p_return_str = "Proxy connection."
End If
Get_InternetConnectedState = True
Else
'not connected.
p_return_str = "Not connected."
Get_InternetConnectedState = False
End If
ByRef is a VB keyword that specifies a variable to be passed as a parameter BY REFERENCE. In other words, the pointer to the variable is passed and any change to its value made within the function or sub will change its value outside the function/sub.
4/25/2007 3:19:29 AM - anonymous
ByRef is a VB keyword that specifies a variable to be passed as a parameter BY REFERENCE. In other words, the pointer to the variable is passed and any change to its value made within the function or sub will change its value outside the function/sub.
4/25/2007 3:19:29 AM - anonymous
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).