Desktop Functions: Smart Device Functions:
|
Search Results for "connect" in [All]winscard1: SCardConnect
[DllImport("winscard.dll", EntryPoint="SCardConnect", CharSet=CharSet.Auto)]
static extern int SCardConnect(
rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, error CS1502: The best overloaded method match for 'PCSC_ContactlessNet.SmartCard.SCardConnect(System.IntPtr, string, uint, uint, out int, out uint)' has some invalid arguments
static extern int SCardConnect(IntPtr hContext,
static extern int SCardDisconnect(IntPtr hCard, int Disposition);
result = SCardConnect(hContext, readerName, 2, 3, ref phCard, ref ActiveProtocol);
SCardDisconnect(phCard, 0);
IntPtr hCard, // Reference value returned from SCardConnect
// Copy code to connect to the card here 5: SCardStatus updated to better working signature (VS2010)...still need to establish context, and connect the card like in sample area, but this is an example of code that will read an iClass UID
// Paste here code for SCardEstablishContext, SCardConnect
// Paste here code for SCardDisconnect, pbRecvBuffer contains Answer as Byte[] odbc32
static extern short SQLAllocConnect(IntPtr EnvironmentHandle, out IntPtr ConnectionHandle);
IntPtr connectionHandle = IntPtr.Zero;
if (!isOK(SQLAllocConnect(environmentHandle, out connectionHandle)))
throw new Exception("Failed to allocate connection handle.");
private static extern short SQLBrowseConnect(IntPtr hconn, StringBuilder inString,
if (SQL_NEED_DATA == SQLBrowseConnect(hconn, inString, inStringLength, outString,
if (SQL_NEED_DATA != SQLBrowseConnect(hconn, inString, inStringLength, outString, 9: SQLAllocStmt
static extern short SQLAllocStmt(IntPtr ConnectionHandle, out IntPtr StatementHandle);
Private Shared Function SQLAllocStmt(ByVal connectionHandle As IntPtr, <Runtime.InteropServices.Out()> _ 10: SQLBindCol
//We will use a DSN in our connection string
string connectionString = "DSN=SomeDSN; Uid=myun; Pwd=mypwd;";
//Allocate a database connection handle, using the environment handle we allocated earlier
//Connect to the DB, the completed connection string will be passed back
short retcode = SQLDriverConnect(dbcHandle, IntPtr.Zero, connectionString, 256, completedConnString, 1024, out strLength, SQL_DRIVER_COMPLETE);
//Free resources and disconnect
SQLDisconnect(dbcHandle); 11: SQLBrowseConnect
private static extern short SQLBrowseConnect( IntPtr handleConnection, StringBuilder connectionString, short stringLength, StringBuilder outConnection, short bufferLength, out short stringLength2Ptr );
Declare Function SQLBrowseConnect Lib "odbc32.dll" (TODO) As TODO 12: SQLConnect
static extern short SQLConnect (int connectionHandle, string serverName,
Private Function SQLConnect(ByVal hDBc As IntPtr, ByVal servername As String, ByVal serverlen As Short, _
RetCode = SQLAllocConnect(hEnv,ref hdbc);
RetCode = SQLConnect(hdbc, "Northwind",-3,null,-3,null,-3); 13: SQLDataSources
Private Sub OnGetODBCConnectionNames(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbExpSID.DropDown, cmbImpSid.DropDown 14: SQLDisconnect
public static extern short SQLDisconnect(IntPtr ConnectionHandle);
Declare Function SQLDisconnect Lib "odbc32.dll" ( _
connectionHandle As Integer) As Short See SQLDriverConnect. 15: SQLDriverConnect
public static extern short SQLDriverConnect(IntPtr hdbc,
Private Shared Function SQLDriverConnect(ByVal hdbc As IntPtr, ByVal hwnd As IntPtr, ByVal szConnStrIn As String, _
void driverConnect(string connstr, ushort driverCompletion)
const short MAX_CONNECT_LEN = 1024;
StringBuilder out_connect = new StringBuilder(MAX_CONNECT_LEN);
string in_connect = connstr;
if (!isOK(SQLDriverConnect(connectionHandle,
in_connect,
(short) in_connect.Length,
out_connect,
MAX_CONNECT_LEN,
string msg = GetError(IntPtr.Zero) + "\nconnection string:\n\t" + connstr;
connectionHandle,
if (!isOK(SQLAllocConnect(environmentHandle, out connectionHandle)))
throw new Exception("Failed to allocate connection handle.");
if (connectionHandle.ToInt32()!=0)
SQLDisconnect(connectionHandle);
if (connectionHandle.ToInt32()!=0)
SQLFreeConnect(connectionHandle);
connectionHandle = IntPtr.Zero; 16: SQLError
IntPtr ConnectionHandle, See SQLDriverConnect example. 17: SQLFreeConnect 18: SQLFreeEnv See SQLDriverConnect example. 19: SQLFreeHandle 20: SQLTables
if (!isOK(SQLAllocStmt(connectionHandle, out statementHandle))) winmm21: 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); 22: 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); gdiplus23: GdipAddPathPath
bool connect); user3224: DdeConnect
static extern IntPtr DdeConnect(uint idInst, IntPtr hszService, IntPtr handle = DdeConnect(instanceId, serviceHandle, topicHandle, IntPtr.Zero); 25: DdeConnectList 26: DdeDisconnect 28: DdeReconnect dhcpsapi
//left connected overnight should have their IP dynamic lease left untouched.
SqlConnection sqlConnection1 = new SqlConnection("Data Source=" + SqlServer + ";Initial Catalog=DhcpDB;Persist Security Info=True;User ID=user");
SqlCommand selCommand = new SqlCommand(strSQL, sqlConnection1);
sqlConnection1.Open();
sqlConnection1.Close(); ole3231: CoInitialize
Connect = 2,
Connect = 2, iphlpapi
IF_TYPE_FRAMERELAY_INTERCONNECT = 58, // Obsolete, use 32 or 44
IF_TYPE_ESCON = 73, // IBM Enterprise Systems Connection
IF_TYPE_PROP_CNLS = 89, // Proprietary Connectionless Proto
IF_TYPE_FRAMERELAY_MPI = 92, // Multiproto Interconnect over FR
public enum NET_IF_CONNECTION_TYPE : uint
NET_IF_CONNECTION_DEDICATED = 1,
NET_IF_CONNECTION_PASSIVE = 2,
NET_IF_CONNECTION_DEMAND = 3,
NET_IF_CONNECTION_MAXIMUM = 4
public NET_IF_CONNECTION_TYPE ConnectionType;
public static List<MIB_TCPROW_OWNER_PID> GetAllTCPConnections()
return GetTCPConnections<MIB_TCPROW_OWNER_PID, MIB_TCPTABLE_OWNER_PID>(AF_INET);
public static List<MIB_TCP6ROW_OWNER_PID> GetAllTCPv6Connections()
return GetTCPConnections<MIB_TCP6ROW_OWNER_PID, MIB_TCP6TABLE_OWNER_PID>(AF_INET6);
private static List<IPR> GetTCPConnections<IPR, IPT>(int ipVersion)//IPR = Row Type, IPT = Table Type
public MIB_TCPROW_OWNER_PID[] GetAllTcpConnections()
TCP_TABLE_BASIC_CONNECTIONS,
TCP_TABLE_OWNER_PID_CONNECTIONS,
TCP_TABLE_OWNER_MODULE_CONNECTIONS,
public List<MIB_TCPROW_OWNER_PID> GetAllTCPv4Connections() {
return GetTCPConnections<MIB_TCPROW_OWNER_PID, MIB_TCPTABLE_OWNER_PID>(AF_INET);
public List<MIB_TCP6ROW_OWNER_PID> GetAllTCPv6Connections() {
return GetTCPConnections<MIB_TCP6ROW_OWNER_PID, MIB_TCP6TABLE_OWNER_PID>(AF_INET6);
public List<IPR> GetTCPConnections<IPR, IPT>(int ipVersion) { //IPR = Row Type, IPT = Table Type
$y=$x.GetAllTCPv4Connections() 36: GetIfTable
/// MIB_IFROW structure array. Content the active networks connection 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); 44: 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)); aygshellMicrosoft.SmartDevice.Connectivity.Device.ProvisionDevice(string, Device.ConfigActions), although it is a desktop managed method and only works remotely, whereas this P/Invoke can be executed directly on the device. advapi32
throw new Exception(String.Format("Error connecting to Service Control Manager. Error provided was: 0x{0:X}", Marshal.GetLastWin32Error()));
throw new Exception(String.Format("Error connecting to Service Control Manager. Error provided was: 0x{0:X}", Marshal.GetLastWin32Error())); 50: DefaultPassword 51: DeleteService
SC_MANAGER_CONNECT = 0x00001,
SC_MANAGER_CONNECT |
private enum ServiceControlManagerType { SC_MANAGER_CONNECT = 0x1, SC_MANAGER_CREATE_SERVICE = 0x2, SC_MANAGER_ENUMERATE_SERVICE = 0x4, SC_MANAGER_LOCK = 0x8, SC_MANAGER_QUERY_LOCK_STATUS = 0x10, SC_MANAGER_MODIFY_BOOT_CONFIG = 0x20, SC_MANAGER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG }
SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = 0x00000014,
SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = &H14UI
SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = 0x00000014,
SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = &H14UI 55: LsaOpenPolicy To administer the local security policy of a local or remote system, you must call the LsaOpenPolicy function to establish a session with that system's LSA subsystem. LsaOpenPolicy connects to the LSA of the target system and returns a handle to the Policy object of that system. You can use this handle in subsequent LSA function calls to administer the local security policy information of the target system. 56: OpenSCManager
/// Required to connect to the service control manager.
SC_MANAGER_CONNECT = 0x00001,
SC_MANAGER_CONNECT |
SC_MANAGER_CONNECT | SC_MANAGER_LOCK,
''' Required to connect to the service control manager.
SC_MANAGER_CONNECT = &H1
SC_MANAGER_CONNECT Or _
SC_MANAGER_CONNECT Or SC_MANAGER_LOCK
Const SC_MANAGER_CONNECT As Int32 = &H1
SC_MANAGER_CONNECT Or _
static extern int RegConnectRegistry(string lpmachineName, int hKey, ref int phKResult);
Declare Auto Function RegConnectRegistry Lib "Advapi32" ( _
LONG RegConnectRegistry(
ret = RegConnectRegistry("\\" & RemotePC, New IntPtr(Hive), hRemoteKey)
iResult = ConnectToRemoteReg(@"\\" + computerName, HKEY_LOCAL_MACHINE, ref bOK);
con = sValue; //'0' connection exists
private int ConnectToRemoteReg(string computerName, int HKEY, ref bool bOK)
iReturn = RegConnectRegistry(computerName, HKEY, ref iResult); 58: RegLoadKey When run from a remote PC (via RegConnectRegistry), the path to the hive file is local to that PC.
LPTSTR lpConnectionName;
public IntPtr lpConnectionName;
public string connectionName;
const int ERROR_NOT_CONNECTED = 2250;
// if the return value is ERROR_NOT_CONNECTED, then
if (apiRetVal == ERROR_NOT_CONNECTED)
retVal.connectionName = Path.GetPathRoot(localPath);
retVal.connectionName = Marshal.PtrToStringAuto(rni.lpConnectionName);
Throw New ArgumentException("Not Connected")
<MarshalAs(UnmanagedType.LPTStr)> Public ConnectionName As String
Private Const ERROR_NOT_CONNECTED As Integer = 2250
Private _connect As String
''' Gets the Connection or UNC Initial Share Point [\\ComputerName\Share]
Public ReadOnly Property Connection() As String
Return _connect
''' Gets the Path location within the Connection to the Directory or File
If _local.Assign(_error = ERROR_NOT_CONNECTED) Then
_connect = IO.Path.GetPathRoot(_origpath)
_path = _origpath.Substring(_connect.Length)
_unc = String.Format(UNCFMT, My.Computer.Name, _connect(0), _path)
_connect = Marshal.PtrToStringAuto(rni.lpConnectionName)
Public lpConnectionName As IntPtr wininet60: 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) Cut off search results after 60. Please refine your search. |