zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    python
    基于vue的npm发包
    div实现水平垂直居中
    element-ui中表格添加fixed定位列后 出现表格错位现象
    解决github经常无法访问的问题
    快排算法C语言实现
    ubuntu下qt运行时/usr/bin/ld: cannot find -lGL
    llinux装完qt 启动qtcreator报错
    LINUX权限-bash: ./startup.sh: Permission denied
    In short, don’t use a pointer to a string literal if you plan to alter the string.
  • 原文地址:https://www.cnblogs.com/rosesmall/p/3054995.html
Copyright © 2011-2022 走看看