Desktop Functions: Smart Device Functions:
|
Search Results for "connect" in [All]secur32
public const int ISC_REQ_CONNECTION = 0x00000800;
public const int STANDARD_CONTEXT_ATTRIBUTES = ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONNECTION;
/// <param name="LsaHandle">[in] Handle obtained from a previous call to LsaRegisterLogonProcess or LsaConnectUntrusted.</param>
public static extern WinStatusCodes LsaConnectUntrusted([Out] out IntPtr LsaHandle);
Declare Function LsaConnectUntrusted Lib "secur32.dll" (TODO) As TODO
NewCredentials, // Allows the caller to clone its current token and specify new credentials for outbound connections. 6: LsaLogonUser
public static extern WinStatusCodes LsaConnectUntrusted([Out] out IntPtr LsaHandle);
OSCalls.WinStatusCodes status = OSCalls.LsaConnectUntrusted(out lsaHandle); comdlg327: FtpCommand
static extern bool FtpCommand(IntPtr hConnect, bool fExpectResponse, [MarshalAs(UnmanagedType.U4)] int dwFlags, string lpszCommand, IntPtr dwContext, ref IntPtr phFtpCommand);
Private Shared Function FtpCommand(ByVal hConnect As IntPtr, ByVal fExpectResponse As Boolean, <MarshalAs(UnmanagedType.U4)> ByVal dwFlags As Integer, ByVal lpszCommand As String, ByVal dwContext As IntPtr, ByRef phFtpCommand As IntPtr) As Boolean mpr
static extern int MultinetGetConnectionPerformance(
ref NetConnectInfoStruct lpNetConnectInfoStruct);
public struct NetConnectInfoStruct {
/// In the absence of information about the actual connection,
/// the current connection with the resource, with any routing
/// The connection is not being routed.
/// If this flag is not set, the connection may be going through
/// The connection is over a medium that is typically slow (for
NetConnectInfoStruct ci = new NetConnectInfoStruct();
RESOURCE_CONNECTED = 1,
RESOURCEUSAGE_CONNECTABLE = 0x00000001,
RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),
public enum ResourceConnection
CONNECT_UPDATE_PROFILE = 1,
CONNECT_UPDATE_RECENT = 2,
CONNECT_TEMPORARY = 4,
CONNECT_INTERACTIVE = 8,
CONNECT_PROMPT= 0X10,
CONNECT_REDIRECT = 0X80,
CONNECT_CURRENT_MEDIA = 0X200,
CONNECT_COMMAND_LINE = 0X800,
CONNECT_CMD_SAVECRED = 0X1000,
CONNECT_CRED_RESET = 0X2000 private static extern int WNetAddConnection2( NETRESOURCE lpNetResource,
Declare Function VVNetAddConnection2 Lib "mpr.dll" (TODO) As TODO nr.dwUsage = ResourceUsage.RESOURCEUSAGE_CONNECTABLE; int result = WNetAddConnection2(nr, password, user, (int)ResourceConnection.CONNECT_TEMPORARY);
private static extern int WNetAddConnection3(IntPtr hWndOwner,
Private Shared Function WNetAddConnection3(ByVal hWndOwner As IntPtr, _
private const int CONNECT_INTERACTIVE = 0x8;
private const int CONNECT_PROMPT = 0x10;
WNetAddConnection3(hWnd, ref ConnInf, null, null,
CONNECT_INTERACTIVE | CONNECT_PROMPT); http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp The WNetAddConnection2 function supersedes the WNetAddConnection function. If you can pass a handle to a window that the provider of network resources can use as an owner window for dialog boxes, call the WNetAddConnection3 function instead.
public static extern int WNetAddConnection2(ref NETRESOURCE netResource,
public static extern int WNetAddConnection2(NETRESOURCE netResource,
// RESOURCE_CONNECTED = 1,
// RESOURCEUSAGE_CONNECTABLE = 0x00000001,
// RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),
// [DllImport("Mpr.dll", EntryPoint="WNetAddConnection2", CallingConvention=CallingConvention.Winapi)]
// private static extern ErrorCodes WNetAddConnection2(NETRESOURCE lpNetResource,ref string lpPassword,ref
public static extern int WNetAddConnection2( [In] NETRESOURCE netResource,
Declare Function WNetAddConnection2 Lib "mpr.dll" (ByRef netResource As _
Declare Function WNetAddConnection2 Lib "mpr.dll" (netResource As _ // int ret = WNetAddConnection2( myNetResource, "username", "password", 0);
int ret = WNetAddConnection2( myNetResource, "password", "username", 0); //by honglinlee
public class NetworkConnection : IDisposable
public NetworkConnection(string networkName,
var result = WNetAddConnection2(
throw new IOException("Error connecting to remote share",
~NetworkConnection()
WNetCancelConnection2(_networkName, 0, true);
private static extern int WNetAddConnection2(NetResource netResource,
private static extern int WNetCancelConnection2(string name, int flags,
Connected = 1,
RESOURCE_CONNECTED = 1,
RESOURCEUSAGE_CONNECTABLE = 0x00000001,
RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),
private static extern int WNetAddConnection2(NETRESOURCE lpNetResource, string lpPassword, string lpUsername, int dwFlags);
int result = WNetAddConnection2(myNetResource, password, user, 0); This is a function which connects to a share. Will throw a message box with any errors. Example connect code: ConnectDrive("\\server\share", "s:", "username", "password")
Public Function ConnectDrive(ByVal RemoteName As String, ByVal LocalName As String, Optional ByVal username As String = Nothing, Optional ByVal password As String = Nothing)
returnValue = WNetAddConnection2(myResource, password, username, 0)
MsgBox("Could not connect to " & myResource.RemoteName & ". The server said this: " & vbNewLine & vbNewLine & "(Error " & returnValue & ") " & errorM)
private static extern int WNetAddConnection3(IntPtr hWndOwner,
Private Shared Function WNetAddConnection3(ByVal hWndOwner As IntPtr, _
private const int CONNECT_INTERACTIVE = 0x8;
private const int CONNECT_PROMPT = 0x10;
WNetAddConnection3(hWnd, ref ConnInf, null, null,
CONNECT_INTERACTIVE | CONNECT_PROMPT); http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp
static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce);
Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Integer, ByVal fForce As Integer) As Integer
''' The WNetCancelConnection2 function cancels an existing network connection.
''' You can also call the function to remove remembered network connections that are not currently connected.
Private Shared Function WNetCancelConnection2(ByVal lpName As String, _ The system updates the user profile with the information that the connection is no longer a persistent one if you pass this constant as <dwFlags>
private const int CONNECT_UPDATE_PROFILE = 0x1;
public static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool fForce);
private const int CONNECT_UPDATE_PROFILE = 0x1;
int result=WNetCancelConnection2("Y:", CONNECT_UPDATE_PROFILE, true);
static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce);
Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long
''' The WNetCancelConnection2 function cancels an existing network connection.
''' You can also call the function to remove remembered network connections that are not currently connected.
Private Shared Function WNetCancelConnection2(ByVal lpName As String, _ The system updates the user profile with the information that the connection is no longer a persistent one if you pass this constant as <dwFlags>
private const int CONNECT_UPDATE_PROFILE = 0x1;
public static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool fForce);
private const int CONNECT_UPDATE_PROFILE = 0x1;
int result=WNetCancelConnection2("Y:", CONNECT_UPDATE_PROFILE, true); 15: WNetEnumResource
RESOURCE_CONNECTED = 0x00000001,
RESOURCEUSAGE_CONNECTABLE =0x00000001,
RESOURCEUSAGE_ALL =(RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),
RESOURCE_CONNECTED = &H1
RESOURCEUSAGE_CONNECTABLE = &H1
RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE Or RESOURCEUSAGE_CONTAINER Or RESOURCEUSAGE_ATTACHED)
public static extern int WNetGetConnection([MarshalAs(UnmanagedType.LPTStr)] string localName, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder remoteName, ref int length);
Shared Function WNetGetConnection(<MarshalAs(UnmanagedType.LPTStr)> _
Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal localName As String, ByVal remoteName As System.Text.StringBuilder, ByRef length As Integer) As Integer rc = WNetGetConnection("p:", rname, ref bsize);
Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal localName As String, _
WNetGetConnection(Microsoft.VisualBasic.Left(path, 2), UNC, length)
Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" _
Dim err As Integer = WNetGetConnection(theDriveName, uncPathBuf, uncPathBuf.Capacity)
private static extern int WNetUseConnection
Connect dwFlags,
Declare Function WNetUseConnection Lib "mpr.dll" (TODO) As TODO
CONNECTED = 0x00000001,
CONNECTABLE = 0x00000001,
public enum Connect
public static void UseConnection(string localName, string remoteName, string username, string password)
ThrowIfError(WNetUseConnection(IntPtr.Zero, nr, password, username, 0, null, null, null));
public static void UseConnection(string localName, string remoteName, bool promptUser = false)
ThrowIfError(WNetUseConnection(IntPtr.Zero, nr, null, null, promptUser ? Connect.INTERACTIVE | Connect.PROMPT : 0, null, null, null)); quickusb18: QuickUSB
LastError = "USB connection not open, please open"; 19: QuickUsbClose This function will return a null delimited "\0" list of attached devices. For example, after executing this function with one module connected, nameList will contain "QUSB-0\0\0". If there are two devices plugged in, nameList will contain "QUSB-0\0QUSB-1\0\0". 21: QuickUsbReadData
LastError = "USB Connection is not open";
LastError = "USB connection not open, please open"; gdiplus23: GdipAddPathPath
bool connect); hidRetrieves the serial number string from a connected device. Structures25: AudioLineStatus
MIXERLINE_LINEF_DISCONNECTED = &H8000
public bool fConnected;
internal bool fReturnConnected; 30: MIXERLINE
DISCONNECTED = 0x00008000u, 31: NETRESOURCE Without the Structlayout the WNetAddConnection2 does not work !!! 32: RASDIALPARAMS 33: 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) 36: 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; coredll53: CeRunAppAtEvent
NOTIFICATION_EVENT_RS232_DETECTED is also raised when connecting the device to USB.
private static extern uint RasEnumConnections(
[Out] out int connections); public static RASCONN[] GetAllConnections()
RASCONN[] allConnections = tempConn;
int lpcConnections = 0;
uint ret = RasEnumConnections(tempConn, ref lpcb, out lpcConnections);
// first call returned that there are more than one connections
allConnections = new RASCONN[lpcb / Marshal.SizeOf(typeof(RASCONN))];
allConnections[0] = tempConn[0];
ret = RasEnumConnections(allConnections, ref lpcb, out lpcConnections);
if (lpcConnections > allConnections.Length)
throw new Exception("RAS: error retrieving correct connection count");
else if (lpcConnections == 0)
allConnections = new RASCONN[0];
return allConnections;
internal static extern UInt32 RasEnumConnections([In, Out] _RASCONN[] lprasconn, ref UInt32 lpcb, ref UInt32 lpcConnections);
public IntPtr ConnectionHandle { get { return m_hrasconn; } }
public static _RASCONN[] EnumerateConnections()
if (RasEnumConnections(rasconn, ref size, ref noelements) != 0x00)
if (RasEnumConnections(rasconn, ref size, ref noelements) != 0x00) { rasconn = null; }
public static extern int RasGetConnectStatus(IntPtr hrasconn, ref RASCONNSTATUS lprasconnstatus);
RASCS_ConnectDevice,
RASCS_DeviceConnected,
RASCS_AllDevicesConnected,
RASCS_Connected = RASCS_DONE,
RASCS_Disconnected
public static RASCONNSTATUS GetConnectStatus(IntPtr hrasconn)
RasGetConnectStatus(hrasconn, ref status); 57: RasHangUp Use this function together with RasEnumConnections, to return a list of the active connections, then the sample code below will loop through the RASCONN[] array and close each one. public static void CloseAllConnections()
RASCONN[] connections = GetAllConnections();
for (int i = 0; i < connections.Length; ++i)
RasHangUp(connections[i].hrasconn); winspool58: AddPrinter
internal static extern bool AddPrinterConnection(String pszBuffer);
Declare Function AddPrinterConnection Lib "winspool.dll" (TODO) As TODO
internal static extern bool AddPrinterConnection(String pszBuffer);
Declare Function AddPrinterConnection Lib "winspool.dll" (TODO) As TODO 60: ClosePrinter Cut off search results after 60. Please refine your search. |