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

  • 相关阅读:
    编写OracleMembershipProvider,让SharePoint2007使用Oralce中的用户数据实现Form验证。 (第三天)
    学习《Building Applications with FME Objects》 之一 关于FME Objects
    我们在这里期待~~
    用python写fme数据转换脚本
    学习《Building Applications with FME Objects》 之七 坐标系统
    菜鸟笔记Linq初学 top(2)
    菜鸟笔记Linq初学 top(1)
    Sqlserver2008R2搭建本地服务器
    Python3之列表、元组和购物车程序练习
    Python3之字符串
  • 原文地址:https://www.cnblogs.com/rosesmall/p/3054995.html
Copyright © 2011-2022 走看看