高级: 需要专家编码、 互操作性,和多用户技能。
在 Microsoft Access 97 中,.ldb 文件用于确定共享数据库中以及由谁锁定的记录。它是任何用户打开数据库,并删除最后一个用户关闭数据库时自动创建的。虽然直接进行读取,不能打开.ldb 文件,Microsoft 提供了公开可以读取.ldb 文件使用的函数的动态链接库。本文包含的代码示例使用 DLL 读取.ldb 文件。
Microsoft 提供的编程示例只,用于说明不附带任何明示或暗示保证。这包括,但不限于对适销性或针对特定用途的适用性的暗示的担保。本文假定您熟悉演示了正在使用的编程语言以及用于创建和调试过程的工具。Microsoft 支持工程师可以帮助解释某个特定过程的功能,但他们不会修改这些示例以提供额外的功能或构建过程来满足您的具体要求。
动态链接库 Msldbusr.dll 包含函数,使您能够执行以下操作:
- 查看已登录到数据库中,自创建.ldb 文件以来的所有计算机。
- 查看当前登录到数据库的计算机。
- 查看导致可能已损坏的数据库文件的计算机。
- 查看计算机登录到数据库的计数。
Msldbusr.dll 是 Jetutils.exe 文件的一部分。有关 Jetutils.exe 或 Msldbusr.dll 以及其用法的详细信息,请参阅 Microsoft 知识库中下面的文章:
176670
(http://support.microsoft.com/kb/176670/EN-US/
)
可用 ACC: Microsoft Jet 实用工具,在下载中心中
下面的示例 Visual Basic 应用程序代码调用可打印的计算机当前连接到在调试窗口中的数据库列表 Msldbusr.dll LDBUser_GetUsers 的函数。
安装 Msldbusr.dll C:\Windows\System (Microsoft Windows 95) 或 C:\Winnt\System32 (Microsoft Windows NT) 文件夹后, 请按照以下步骤创建并使用该示例函数:
- 在 Microsoft Access 97 中创建新的模块
- 键入或粘贴到模块的声明部分的下面的函数声明语句:
Declare Function LDBUser_GetUsers Lib "MSLDBUSR.DLL" _
(lpszUserBuffer() As String, ByVal lpszFilename As String, _
ByVal nOptions As Long) As Integer
- 键入或粘贴到模块的下面的示例函数:
Public Function GetUsers(Optional StrDbPath As String)
ReDim lpszUserBuffer(1) As String
Dim intLooper As Integer
Dim Cusers As Long
Dim strMsgBox As String
On Error GoTo Err_GetUsers
' Check to see if a database path was passed
' to the function. If the argument was not used,
' assume that we're to investigate the .ldb
' of the current database.
If IsMissing(StrDbPath) Or StrDbPath = "" Then
StrDbPath = CurrentDb.Name
End If
' Set Cusers to the number of computers currently connected
' to the database. Insert computer information into the
' lpszUserBuffer array.
' Arguments of LdbUser_Get Users:
' 1 = All users who have logged in since the LDB file was
' created
' 2 = Only users who are currently logged in
' 4 = Only users who are causing the database file to be
' corrupted
' 8 = Just return the count of users
Cusers = LDBUser_GetUsers(lpszUserBuffer(), StrDbPath, 2)
' Print possible errors returned by the function.
Select Case Cusers
Case -1
strMsgBox = "Can't open the LDB file"
Case -2
strMsgBox = "No user connected"
Case -3
strMsgBox = "Can't Create an Array"
Case -4
strMsgBox = "Can't redimension array"
Case -5
strMsgBox = "Invalid argument passed"
Case -6
strMsgBox = "Memory allocation error"
Case -7
strMsgBox = "Bad index"
Case -8
strMsgBox = "Out of memory"
Case -9
strMsgBox = "Invalid Argument"
Case -10
strMsgBox = "LDB is suspected as corrupted"
Case -11
strMsgBox = "Invalid argument"
Case -12
strMsgBox = "Unable to read MDB file"
Case -13
strMsgBox = "Can't open the MDB file"
Case -14
strMsgBox = "Can't find the LDB file"
End Select
If Not IsEmpty(strMsgBox) And strMsgBox <> "" Then
MsgBox strMsgBox, vbCritical, "Error"
Exit Function
End If
' Print computer names to Debug window.
For intLooper = 0 To Cusers - 1
Debug.Print "User"; intLooper + 1; ":"; _
lpszUserBuffer(intLooper)
Next
Exit_GetUsers:
Exit Function
Err_GetUsers:
MsgBox Err.Description
Resume Exit_GetUsers
End Function
- 若要测试此函数,在调试窗口中键入下面一行,然后按 ENTER 键:
有关 Msldbusr.dll 的详细信息,查看 Jetutils.exe 中找到该 Msldbusr.doc 文件。
文章编号: 186304 - 最后修改: 2007年1月23日 - 修订: 4.3
| kbmt kbhowto kbprogramming KB186304 KbMtzh |
机器翻译注意:这篇文章是由无人工介入的微软自动的机器翻译软件翻译完成。微软很高兴能同时提供给您由人工翻译的和由机器翻译的文章, 以使您能使用您的语言访问所有的知识库文章。然而由机器翻译的文章并不总是完美的。它可能存在词汇,语法或文法的问题,就像是一个外国人在说中文时总是可能犯这样的错误。虽然我们经常升级机器翻译软件以提高翻译质量,但是我们不保证机器翻译的正确度,也不对由于内容的误译或者客户对它的错误使用所引起的任何直接的, 或间接的可能的问题负责。
点击这里察看该文章的英文版:
186304
(http://support.microsoft.com/kb/186304/en-us/
)
Microsoft和/或其各供应商对于为任何目的而在本服务器上发布的文件及有关图形所含信息的适用性,不作任何声明。 所有该等文件及有关图形均"依样"提供,而不带任何性质的保证。Microsoft和/或其各供应商特此声明,对所有与该等信息有关的保证和条件不负任何责任,该等保证和条件包括关于适销性、符合特定用途、所有权和非侵权的所有默示保证和条件。在任何情况下,在由于使用或运行本服务器上的信息所引起的或与该等使用或运行有关的诉讼中,Microsoft和/或其各供应商就因丧失使用、数据或利润所导致的任何特别的、间接的、衍生性的损害或任何因使用而丧失所导致的之损害、数据或利润不负任何责任。
不再更新的 KB 内容免责声明本文介绍那些 Microsoft 不再提供支持的产品。因此本文按“原样”提供,并且不再更新。