Desktop Functions: Smart Device Functions:
|
Search Results for "connect" in [All]wininet1: FtpCommand hConnect (in) A handle returned from a call to InternetConnect. fExpectResponse (in) A Boolean value that indicates whether the application expects a data connection to be established by the FTP server. This must be set to TRUE if a data connection is expected, or FALSE otherwise.
Dim ret As Boolean = FTPCommandA(ConnectionHandle, False, 0, sCommand, IntPtr.Zero, IntPtr.Zero)
static extern bool FtpCreateDirectory(IntPtr hConnect, string lpszDirectory);
Private Shared Function FtpCreateDirectory(ByVal hConnect As IntPtr, ByVal lpszDirectory As String) As Boolean
static extern bool FtpDeleteFile(IntPtr hConnect, string fileName);
(ByVal hConnect As IntPtr, ByVal fileName As String) _
static extern IntPtr FtpFindFirstFile(IntPtr hConnect,
(ByVal hConnect As IntPtr, ByVal searchFile As String, _
static extern bool FtpGetCurrentDirectory(IntPtr hConnect,
(ByVal hConnect As IntPtr, ByVal directory As StringBuilder, ByRef bufferLength As Integer) _
' and Me.hINetConn is an IntPtr opened by InternetConnect 6: FtpGetFile
static extern bool FtpGetFile(IntPtr hConnect, string remoteFile,
Declare Function FtpGetFile Lib "wininet.dll" (ByVal hConnect As IntPtr, _
[DllImport("wininet.dll", EntryPoint = "InternetConnectW", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr InternetConnectW(
public void Connect()
ftpHandle = InternetConnectW(internetHandle, FTPSite,
public void Disconnect()
Connect();
Connect();
Disconnect(); 7: FtpPutFile
static extern bool FtpPutFile(IntPtr hConnect, string lpszLocalFile, string lpszNewRemoteFile, int dwFlags, IntPtr dwContext); Call InternetOpen() and InternetConnect() to get a valid hConnect handle.
(ByVal hConnect As Integer, ByVal lpszExisting As String, _ Call InternetOpen() and InternetConnect() to get a valid hConnect handle.
static extern bool FtpSetCurrentDirectory(IntPtr hFtpConnection, string lpszDirectory);
Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hConnect As IntPtr, ByVal lpszDirectory As String) As Boolean 10: HttpOpenRequest
IntPtr hConnect,
__in HINTERNET hConnect,
static extern int InternetAttemptConnect(int dwReserved);
Public Declare Function InternetAttemptConnect Lib "wininet" (Optional ByVal dwReserved As Long = 0) As Long If the computer is already connected, the function may hang.
' This function tries to connect to the internet. If it works, it returns True,
Private Declare Function InternetAttemptConnect Lib "wininet" (Optional ByVal dwReserved As Integer = 0) As Integer
Public Function ConnectToInternet() As Boolean
If InternetAttemptConnect(0) = 0 Then
static extern bool InternetCheckConnection(string lpszUrl, int dwFlags, int dwReserved);
Declare Function InternetCheckConnection Lib "wininet.dll" (ByVal lpszUrl As String, ByVal dwFlags As Integer, ByVal dwReserved As Integer) As Boolean
private static extern bool InternetCheckConnection(string lpszUrl, int dwFlags, int dwReserved);
bool connectivity;
if (InternetCheckConnection("http://www.google.com/", 1, 0))
connectivity = true; 13: InternetConnect
* Returns a valid handle to the FTP, Gopher, or HTTP session if the connection is successful, or NULL otherwise. To get extended error information, call GetLastError. An application can also use InternetGetLastResponseInfo to determine why access to the service was denied.
static extern IntPtr InternetConnect(
Declare Auto Function InternetConnect Lib "wininet.dll" (
Number of the TCP/IP port on the server to connect to. Can be one of the values in the following list. If this parameter is set to INTERNET_INVALID_PORT_NUMBER, the function uses the default port for the specified service. These values do not cause the function to use this protocol. The value sets the port to be used. A flag must be used to set the service.
INTERNET_SERVICE_FTP INTERNET_CONNECT_FLAG_PASSIVE (Use passive mode in all data connections for this FTP session.) The InternetConnect function is required before communicating with any Internet service. Having a connect function for all protocols, even those that do not use persistent connections, lets an application communicate common information about several requests using a single function call. In addition, this allows for future versions of Internet protocols that do not require a connection to be established for every client request. For FTP sites, InternetConnect actually establishes a connection with the server; for others, such as Gopher, the actual connection is not established until the application requests a specific transaction. For maximum efficiency, applications using the Gopher and HTTP protocols should try to minimize calls to InternetConnect and avoid calling this function for every transaction requested by the user. One way to accomplish this is to keep a small cache of handles returned from InternetConnect; when the user makes a request to a previously accessed server, that session handle is still available. For FTP connections, if lpszUsername is NULL, InternetConnect sends the string "anonymous" as the user name. If lpszPassword is NULL, InternetConnect attempts to use the user's e-mail name as the password. To close the handle returned from InternetConnect, the application should call InternetCloseHandle. This function disconnects the client from the server and frees all resources associated with the connection. 14: InternetDial private static extern Int32 InternetDial(IntPtr hwndParent, string lpszConnectoid, Int32 dwFlags, ref Int32 lpdwConnection, Int32 dwReserved); int nResult = InternetDial(IntPtr.Zero ,"Your connection",(int)InternetDialFlags.INTERNET_DIAL_UNATTENDED ,ref nConnection , 0);
/// Retrieves the connected state of the local system.
/// C++ ( lpdwFlags [out]. Type: LPDWORD )<br />Pointer to a variable that receives the connection description. This
/// <term>Internet Connection State Possible Flags</term>
/// <term>INTERNET_CONNECTION_CONFIGURED (0x40)</term>
/// Local system has a valid connection to the Internet, but it might or might not be currently
/// connected.
/// <term>INTERNET_CONNECTION_LAN (0x02)</term>
/// <description>Local system uses a local area network to connect to the Internet.</description>
/// <term>INTERNET_CONNECTION_MODEM (0x01)</term>
/// <description>Local system uses a modem to connect to the Internet.</description>
/// <term>INTERNET_CONNECTION_MODEM_BUSY (0x08)</term>
/// <term>INTERNET_CONNECTION_OFFLINE (0x20)</term>
/// <term>INTERNET_CONNECTION_PROXY (0x04)</term>
/// <description>Local system uses a proxy server to connect to the Internet.</description>
/// <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.
/// 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
/// is connected.If FALSE is returned, the INTERNET_CONNECTION_CONFIGURED flag may be set to indicate that autodial is
extern static bool InternetGetConnectedState(out int lpdwFlags, int dwReserved);
enum ConnectionStates
Private Declare Function InternetGetConnectedState Lib "wininet.dll" _
Private Enum ConnectionStates InternetGetConnectedStateFlags
private static extern bool InternetGetConnectedState(out int lpdwFlags, int dwReserved);
bool isConnected = InternetGetConnectedState(out flags, 0);
Console.WriteLine(string.Format("Is connected :{0} Flags:{1}", isConnected, flags)); Function Get_InternetConnectedState(ByRef p_lngFlags As Long, Optional ByRef p_return_str As String = "") As Boolean
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."
Get_InternetConnectedState = True
'not connected.
p_return_str = "Not connected."
Get_InternetConnectedState = False Direct Link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/internetgetconnectedstate.asp 16: InternetHangUp 17: InternetOpen
sAgent can be any string, it is just to identify the connection Interfaces
,BINDSTATUS_CONNECTING
// IConnectionPoint errors
CONNECT_E_FIRST = 0x80040200,
CONNECT_E_NOCONNECTION, // there is no connection for this connection id
CONNECT_E_ADVISELIMIT, // this implementation's limit for advisory connections has been reached
CONNECT_E_CANNOTCONNECT, // connection attempt failed
CONNECT_E_OVERRIDDEN, // must use a derived interface to connect
INET_E_CANNOT_CONNECT = 0x800C0004,
INET_E_CONNECTION_TIMEOUT = 0x800C000B,
case HRESULTS.INET_E_CANNOT_CONNECT:
Description = "Cannot Connect";break;
case HRESULTS.INET_E_CONNECTION_TIMEOUT:
Description = "Connection Timeout.";break; 20: IConnector
public interface IConnector
int GetType(out ConnectorType pType);
int ConnectTo([In] IConnector connector);
int Disconnect();
int IsConnected(out bool pbConnected);
int GetConnectedTo([Out, MarshalAs(UnmanagedType.LPArray)] out IConnector ppConTo);
int GetConnectorIdConnectedTo(out string ppwstrConnectorId);
int GetDeviceIdConnectedTo(out string ppwstrDeviceId);
Interface IConnector 21: IDataObject
int DAdvise([In] ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection);
void DUnadvise(int connection); 22: IDeviceTopology
int GetConnectorCount([Out] out int pConnectorCount);
int GetConnector(int nIndex, out IConnector ppConnector); Starting point only - I only got as far as making getconnectorcount and getconnector return valid information on my machine. The other functions may or may not work! 23: IOleObject
void Advise(object pAdvSink, uint pdwConnection);
void Unadvise(uint dwConnection);
TASK_FLAG_RUN_IF_CONNECTED_TO_INTERNET = 0x400, 25: IUICollection
// Connection Sink for listening to collection changes 26: IUIFramework
// Connects the framework and the application hidRetrieves the serial number string from a connected device. winmm28: midiConnect
static extern UInt32 midiConnect(IntPtr hMidi, IntPtr hmo, IntPtr pReserved);
Declare Function midiConnect Lib "winmm.dll" (TODO) As TODO
UInt32 Connect(IntPtr midiInputHandle, IntPtr midiOutputHandle)
return midiConnect(midiInputHandle, midiOutputHandle, IntPtr.Zero); 29: midiDisconnect
static extern UInt32 midiDisconnect(IntPtr hMidi, IntPtr hmo, IntPtr pReserved);
Declare Function midiDisconnect Lib "winmm.dll" (TODO) As TODO
UInt32 Disconnect(IntPtr midiInputHandle, IntPtr midiOutputHandle)
return midiDisconnect(midiInputHandle, midiOutputHandle, IntPtr.Zero); Structures30: AudioLineStatus
MIXERLINE_LINEF_DISCONNECTED = &H8000
public bool fConnected;
internal bool fReturnConnected; 35: MIXERLINE
DISCONNECTED = 0x00008000u, 36: NETRESOURCE Without the Structlayout the WNetAddConnection2 does not work !!! 37: RASDIALPARAMS 38: RAS_STATS
public int dwConnectionDuration;
Public dwConnectionDuration As Integer See docs for RasGetConnectionStatistics
// Connection/Session counts
public int Reconnects;
public int CoreConnects;
public int Lanman20Connects;
public int Lanman21Connects;
public int LanmanNtConnects;
public int ServerDisconnects;
public bool AoAcConnectivitySupported; // Ignore if earlier than Windows 10 (10.0.10240.0) 41: TCP_TABLE_CLASS
TCP_TABLE_BASIC_CONNECTIONS,
TCP_TABLE_OWNER_PID_CONNECTIONS,
TCP_TABLE_OWNER_MODULE_CONNECTIONS,
TCP_TABLE_BASIC_CONNECTIONS
TCP_TABLE_OWNER_PID_CONNECTIONS
TCP_TABLE_OWNER_MODULE_CONNECTIONS
TCP_TABLE_CLASS = (TCP_TABLE_BASIC_LISTENER,TCP_TABLE_BASIC_CONNECTIONS,
TCP_TABLE_OWNER_PID_CONNECTIONS,TCP_TABLE_OWNER_PID_ALL,
TCP_TABLE_OWNER_MODULE_LISTENER,TCP_TABLE_OWNER_MODULE_CONNECTIONS, TCP_TABLE_BASIC_CONNECTIONS A MIB_TCPTABLE table that contains all connected TCP endpoints on the machine is returned to the caller. TCP_TABLE_OWNER_PID_CONNECTIONS A MIB_TCPTABLE_OWNER_PID or MIB_TCP6TABLE_OWNER_PID that all connected TCP endpoints on the machine is returned to the caller. TCP_TABLE_OWNER_MODULE_CONNECTIONS A MIB_TCPTABLE_OWNER_MODULE or MIB_TCP6TABLE_OWNER_MODULE that contains all connected TCP endpoints on the machine is returned to the caller.
public int ConnectionIndex;
ULONG ConnectionIndex;
Request.ConnectionIndex = PortPortNumber;
if (DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero)) Is often used as a type inside a USB_NODE_CONNECTION_INFORMATION_EX structure, hence the need for the "Pack=1"
struct USB_NODE_CONNECTION_DRIVERKEY_NAME
public int ConnectionIndex;
Structure USB_NODE_CONNECTION_DRIVERKEY_NAME Identical to the USB_NODE_CONNECTION_NAME structure
typedef struct _USB_NODE_CONNECTION_DRIVERKEY_NAME {
ULONG ConnectionIndex;
} USB_NODE_CONNECTION_DRIVERKEY_NAME, *PUSB_NODE_CONNECTION_DRIVERKEY_NAME;
USB_NODE_CONNECTION_DRIVERKEY_NAME DriverKey = new USB_NODE_CONNECTION_DRIVERKEY_NAME();
DriverKey.ConnectionIndex = PortPortNumber;
if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, ptrDriverKey, nBytes, ptrDriverKey, nBytes, out nBytesReturned, IntPtr.Zero))
DriverKey = (USB_NODE_CONNECTION_DRIVERKEY_NAME)Marshal.PtrToStructure(ptrDriverKey, typeof(USB_NODE_CONNECTION_DRIVERKEY_NAME));
struct USB_NODE_CONNECTION_INFORMATION_EX
public int ConnectionIndex;
public int ConnectionStatus;
Structure USB_NODE_CONNECTION_INFORMATION_EX
typedef struct _USB_NODE_CONNECTION_INFORMATION_EX {
ULONG ConnectionIndex;
USB_CONNECTION_STATUS ConnectionStatus;
} USB_NODE_CONNECTION_INFORMATION_EX, *PUSB_NODE_CONNECTION_INFORMATION_EX;
int nBytes = Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX));
IntPtr ptrNodeConnection = Marshal.AllocHGlobal(nBytes);
USB_NODE_CONNECTION_INFORMATION_EX NodeConnection = new USB_NODE_CONNECTION_INFORMATION_EX();
NodeConnection.ConnectionIndex = i;
Marshal.StructureToPtr(NodeConnection, ptrNodeConnection, true);
if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes, ptrNodeConnection, nBytes, out nBytesReturned, IntPtr.Zero))
NodeConnection = (USB_NODE_CONNECTION_INFORMATION_EX)Marshal.PtrToStructure(ptrNodeConnection, typeof(USB_NODE_CONNECTION_INFORMATION_EX));
Marshal.FreeHGlobal(ptrNodeConnection);
USB_NODE_CONNECTION_INFORMATION_EX connection = new USB_NODE_CONNECTION_INFORMATION_EX();
connection.ConnectionIndex = i;
size = Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX)) + 32 * Marshal.SizeOf(typeof(USB_PIPE_INFO)); // Assuming 32 should be enough, you can make this larger
IntPtr ptr_connection = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(connection, ptr_connection, true);
if (DeviceIoControl(hHub, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptr_connection, size, ptr_connection, size, out bytes_returned, IntPtr.Zero))
connection = (USB_NODE_CONNECTION_INFORMATION_EX)Marshal.PtrToStructure(ptr_connection, typeof(USB_NODE_CONNECTION_INFORMATION_EX));
if (bytes_returned != Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX)))
int num = (bytes_returned - Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX))) / Marshal.SizeOf(typeof(USB_PIPE_INFO));
IntPtr ptr_pipeinfo = new IntPtr((byte*)ptr_connection.ToPointer()
+ Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX))
Marshal.FreeHGlobal(ptr_connection);
struct USB_NODE_CONNECTION_NAME
public int ConnectionIndex;
Structure USB_NODE_CONNECTION_NAME
typedef struct _USB_NODE_CONNECTION_NAME {
ULONG ConnectionIndex;
} USB_NODE_CONNECTION_NAME, *PUSB_NODE_CONNECTION_NAME;
USB_NODE_CONNECTION_NAME NodeName = new USB_NODE_CONNECTION_NAME();
NodeName.ConnectionIndex = PortPortNumber;
if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes, out nBytesReturned, IntPtr.Zero))
NodeName = (USB_NODE_CONNECTION_NAME)Marshal.PtrToStructure(ptrNodeName, typeof(USB_NODE_CONNECTION_NAME)); You don't use an IOCTL call directly with a USB_STRING_DESCRIPTOR structure. Instead you use a USB_DESCRIPTOR_REQUEST "request packet" with IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION. The USB_STRING_DESCRIPTOR structure is returned at the very end of the request packet. The whole idea of "writing off the edge" of a structure is counter to the way C#/VB.Net was designed to work, so you'll have to make sure to allocate sufficient amount of memory to handle both the "request packet" and the USB_STRING_DESCRIPTOR structure.
Request.ConnectionIndex = PortPortNumber;
if (DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
Byte[] ConnectState;
System.Runtime.InteropServices.ComTypes.FILETIME ConnectTime;
System.Runtime.InteropServices.ComTypes.FILETIME DisconnectTime;
public struct WLAN_CONNECTION_ATTRIBUTES
/// WLAN_CONNECTION_MODE->_WLAN_CONNECTION_MODE
public WLAN_CONNECTION_MODE wlanConnectionMode;
Public Structure WLAN_CONNECTION_ATTRIBUTES
''' WLAN_CONNECTION_MODE->_WLAN_CONNECTION_MODE
Public wlanConnectionMode As WLAN_CONNECTION_MODE
public struct WLAN_CONNECTION_PARAMETERS
public WLAN_CONNECTION_MODE wlanConnectionMode;
Structure WLAN_CONNECTION_PARAMETERS The rationale behind the change in the history for this is because is that he/she wanted to "unmarshal". However, in functions like WlanConnect(), it is used as an "input". So, it needs to be marshaled. Then I believe they should be IntPtr.
public struct WLAN_HOSTED_NETWORK_CONNECTION_SETTINGS
Structure WLAN_HOSTED_NETWORK_CONNECTION_SETTINGS
wlan_notification_acm_connection_start,
wlan_notification_acm_connection_complete,
wlan_notification_acm_connection_attempt_fail,
wlan_notification_acm_disconnecting,
wlan_notification_acm_disconnected,
wlan_notification_acm_connection_start
wlan_notification_acm_connection_complete
wlan_notification_acm_connection_attempt_fail
wlan_notification_acm_disconnecting
wlan_notification_acm_disconnected
wlan_notification_msm_connected,
wlan_notification_msm_disconnected,
public WTS_CONNECTSTATE_CLASS State; msports58: ComDBClose 59: ComDBOpen advapi32
throw new Exception(String.Format("Error connecting to Service Control Manager. Error provided was: 0x{0:X}", Marshal.GetLastWin32Error())); Cut off search results after 60. Please refine your search. |