VB How to access the network server Access database

xiaoxiao2021-03-06  43

'============================= Custom constant ========================================================================================================================================================== ======================= Private Const RESOURCETYPE_DISK = & H1Private Const RESOURCE_GLOBALNET As Long = & H2Private Const RESOURCEDISPLAYTYPE_SHARE = ​​& H3Private Const RESOURCEUSAGE_CONNECTABLE = & H1

'============================= Custom structure ============================================================================================================================================== ========================================================================================================= # Specify local devices LPREMOTENAME AS STRING 'Specifies the remote network name LPComment as string lpprovider as string' Specifies the supplier of network resources End Type

'================================= API declaration =============== =======================================, "" , _ ByVal lpUserName As String, _ ByVal dwFlags As Long _) As LongPrivate Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias ​​"WNetCancelConnection2A" (_ ByVal lpName As String, _ ByVal dwFlags As Long, _ ByVal fForce As Long _) As Long

Public Function Funipcconn (Byval Struename As String, Byval Strusename As String) AS Boolean 'Purpose: To establish a network connection' Back: True ---- Success 'FALSE --- Failed' Note: Strremotename connected to the computer name (eg: //HostName,//192.168.199.144,//HostName/Data) 'strUserName login user name, strPassword the password Dim NetR as NETRESOURCE NetR.dwScope log = RESOURCE_GLOBALNET NetR.dwType = RESOURCETYPE_DISK NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE NetR.lpRemoteName = strRemoteName 'establish a network map funIpcConn = IIf (WNetAddConnection2 (NetR, strPassword, strUserName, 0) = 0, True, False) End Function

Public Function Funipcdisconn (Byval Strname As String) AS Long Funipcdisconn = WNETCANCELCONNECTION2 (Strname, 0, 0) 'It returns the return value of the API END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-74991.html

New Post(0)