翻译:
标题:怎么取得网络注册名和当前登录的用户的计算机名称?
在你应用ACCESS时,调动两个API函数,就可以轻而易举的取得当前网络工作站用户的注册名和计算机的网络名。在您的模块里添加以下两个声明和过程:Private Declare Function api_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function api_GetComputerName Lib "Kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function CNames(UserOrComputer As Byte) As String
'UserorComputer; 1=User, anything else = computer
Dim NBuffer As String
Dim Buffsize As Long
Dim wOK As Long
Buffsize = 256
NBuffer = Space$(Buffsize)
If UserOrComputer = 1 Then
wOK = api_GetUserName(NBuffer, Buffsize)
CNames = Trim$(NBuffer)
Else
Wok = api_GetComputerName(NBuffer, Buffsize)
CNames = Trim$(NBuffer)
End If
End Function
在我们免费的系统信息例子里就包括这样一些有用的系统API函数。
附例:[em01]
[此贴子已经被作者于2005-8-17 12:16:35编辑过]
|