Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "connect" in [All]

winscard

. . .
Summary
The SCardConnect function establishes a connection (using a specific resource manager context) between the calling application and a smart card contained by a specific reader. If no card exists in the specified reader, an error is returned.
.

[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

.
Documentation
[SCardConnect] on MSDN
. . .
Summary
The SCardDisconnect function terminates a connection previously opened between the calling application and a smart card in the target reader.
.

static extern int SCardDisconnect(int hCard, int dwDisposition);

.
Documentation
[SCardDisconnect] on MSDN
.

    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

.
Summary
The SCardStatus function provides the current status of a smart card in a reader. You can call it any time after a successful call to SCardConnect and before a successful call to SCardDisconnect. It does not affect the state of the reader or reader driver.
.

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

.
Summary
SQLAllocConnect allocates memory for a connection handle within the environment identified by henv.
.

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.");

.
Documentation
[SQLAllocConnect] on MSDN
.
Summary
SQLAllocHandle allocates an environment, connection, statement, or descriptor 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,

.
Summary
SQLAllocStmt allocates memory for a statement handle and associates the statement handle with the connection specified by hdbc.
.

static extern short SQLAllocStmt(IntPtr ConnectionHandle, out IntPtr StatementHandle);

.

    Private Shared Function SQLAllocStmt(ByVal connectionHandle As IntPtr, <Runtime.InteropServices.Out()> _

.

            //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);

.
Summary
Supports an iterative method of discovering and enumerating the attributes and attribute values required to connect to a data source.
.

  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

.
Documentation
[SQLBrowseConnect] on MSDN
.

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);

.
Documentation
[SQLConnect] on MSDN
.

    Private Sub OnGetODBCConnectionNames(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbExpSID.DropDown, cmbImpSid.DropDown

.
Summary
SQLDisconnect closes the connection associated with a specific connection handle.
.

public static extern short  SQLDisconnect(IntPtr ConnectionHandle);

.

Declare Function SQLDisconnect Lib "odbc32.dll" ( _

.

   connectionHandle As Integer) As Short

.

See SQLDriverConnect.

.
Documentation
[SQLDisconnect] on MSDN
.
Summary
SQLDriverConnect is an alternative API to SQLConnect. The difference is that it can popup the dialog to ask the user for more information about the connection
.

    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;

.
Documentation
[SQLDriverConnect] on MSDN
.

        IntPtr        ConnectionHandle,

.

See SQLDriverConnect example.

.
Summary
SQLFreeConnect releases a connection handle and frees all memory associated with the handle.
.

  static extern short SQLFreeConnect(IntPtr ConnectionHandle);

.

See SQLDriverConnect example.

.
Documentation
[SQLFreeConnect] on MSDN
.

See SQLDriverConnect example.

.
Summary
SQLFreeHandle frees resources associated with a specific environment, connection, statement, or descriptor handle.
.

        if (!isOK(SQLAllocStmt(connectionHandle, out statementHandle)))

winmm

. .
Summary
Connects a MIDI input device to a MIDI thru or output device, or connects a MIDI thru device to a MIDI output device.
.

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);

.
Documentation
[midiConnect] on MSDN
. .
Summary
Disconnects a MIDI input device from a MIDI thru or output device, or disconnects a MIDI thru device from a MIDI output device.
.

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);

.
Documentation
[midiDisconnect] on MSDN

gdiplus

.

   bool connect);

user32

.
Summary
.

static extern IntPtr DdeConnect(uint idInst, IntPtr hszService,

.

IntPtr handle = DdeConnect(instanceId, serviceHandle, topicHandle, IntPtr.Zero);

.
Documentation
[DdeConnect] on MSDN
.
Summary
.

static extern IntPtr DdeReconnect(IntPtr hConv);

.
Documentation
[DdeReconnect] on MSDN

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();

ole32

.
Summary
Disconnects all remote process connections being maintained on behalf of all the interface pointers that point to a specified object.
.

static extern void CoDisconnectObject(

.
Documentation
[CoDisconnectObject] on MSDN
.

    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()

.

    /// MIB_IFROW structure array. Content the active networks connection

mpr

.
Summary
The MultinetGetConnectionPerformance function returns information about the expected performance of a connection used to access a network resource.
.

    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();

.
Documentation
[MultinetGetConnectionPerformance] on MSDN
.
Summary
.

        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);

.
Documentation
[VVNetAddConnection2] on MSDN
.

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);

.
Documentation
[WNetAddConnection3] on MSDN
.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp

.
Summary
The WNetAddConnection2 function makes a connection to a network resource. The function can redirect a local device to the network resource.
.

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)

.
Documentation
[WNetAddConnection2] on MSDN
.

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);

.
Documentation
[WNetAddConnection3] on MSDN
.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp

.
Summary
The WNetCancelConnection2 function cancels an existing network connection. You can also call the function to remove remembered network connections that are not currently connected.
.

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);

.
Documentation
[WNetCancelConnection2] on MSDN
.
Summary
The WNetCancelConnection2 function cancels an existing network connection. You can also call the function to remove remembered network connections that are not currently connected.
.

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);

.
Documentation
[WNetCancelConnection2] on MSDN
.

    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)

.
Summary
Makes a connection to a network resource. The function can redirect a local device to a network resource.
.

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));

.
Documentation
[WNetUseConnection] on MSDN

aygshell

.

Microsoft.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()));

.
Summary
If you enable autologon, it is more convenient to use Windows; however this feature may pose a security risk. If you set a computer for autologon, anyone who can physically obtain access to the computer can gain access to all of the computer contents, including any network or networks it is connected to. In addition, when autologon is enabled, the password is stored in the registry in plaintext. The specific registry key that stores this value is remotely readable by the Authenticated Users group. This setting is only recommended for cases where the computer is physically secured, and steps have been taken to ensure that untrusted users cannot remotely access the registry.
.

        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

.

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.

.
Summary
The OpenSCManager function establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
.

    /// 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 _

.
Summary
Connect to a remote PC's registry
.

  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);

.
Documentation
[RegConnectRegistry] on MSDN
.

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

wininet

.

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.


 
Access PInvoke.net directly from VS: