• vb怎样访问网络服务器的access数据库


      分类: 【VisualBasic源码】

    '===============自定义常量=====================
    Private Const RESOURCETYPE_DISK = &H1
    Private Const RESOURCE_GLOBALNET    As Long = &H2
    Private Const RESOURCEDISPLAYTYPE_SHARE = &H3
    Private Const RESOURCEUSAGE_CONNECTABLE = &H1

    '==============自定义结构==================
    Private Type NETRESOURCE
       dwScope          As Long
       dwType           As Long '用于指定网络的资源类型
       dwDisplayType    As Long
       dwUsage          As Long
       lpLocalName  As String   '指定本地设备
       lpRemoteName As String   '指定远程网络名
       lpComment    As String
       lpProvider   As String   '指定提供网络资源的供应商
    End Type

    '===================API声明========================
    Private Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" ( _
        lpNetResource As NETRESOURCE, _
        ByVal lpPassword As String, _
        ByVal lpUserName As String, _
        ByVal dwFlags As Long _
        ) As Long

    Private 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 strRemoteName As String, ByVal strUserName As String, ByVal strPassword As String) As Boolean
    '目的:建立网络间的联系
    '返回:  True ---- 成功
    '       False --- 失败
    '注释:strRemoteName为要连接的计算机名称(如:\\HostName、\\192.168.199.144\\HostName\Data)
    '     strUserName为登录的用户名,strPassword为登录的密码
        Dim NetR   As NETRESOURCE
        NetR.dwScope = RESOURCE_GLOBALNET
        NetR.dwType = RESOURCETYPE_DISK
        NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
        NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE
        NetR.lpRemoteName = strRemoteName
        '建立网络映射
        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)     '原样返回API的返回值
    End Function

  • 相关阅读:
    php checkbox 复选框
    wp7 The remote connection to the device has been lost
    php json_decode null
    今入住博客园,希望笑傲职场!
    单例模式之见解设计模式
    简单工厂之见解设计模式
    infopath 序列化 在发布处有导出源文件.存放一地方后有myschema.xsd 文件
    超简单的天气预报webpart
    用户控件传值
    Proxy代理
  • 原文地址:https://www.cnblogs.com/rosesmall/p/3054995.html
Copyright © 2020-2023  润新知