标题: How to Get the Network Log In Name and Computer Name of the Currently Logged [打印本页] 作者: tmtony 时间: 2005-8-5 20:02 标题: How to Get the Network Log In Name and Computer Name of the Currently Logged 标题:How to Get the Network Log In Name and Computer Name of the Currently Logged In User
原作者:ATTAC Consulting Group
Two easy API calls can provide you with network log in name of the current user of the workstation and the network name of the computer itself for use in your Access application. Declare the following functions in your module and add the following function: 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
Our System Information sample mdb in the Free file library contains this an other useful system api functions. 作者: 爱情插班生 时间: 2005-8-9 02:27
翻译:
标题:怎么取得网络注册名和当前登录的用户的计算机名称?
在你应用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