如何在 Access vba 中获取登录用户名? [英] How to get logged-in user's name in Access vba?
本文介绍了如何在 Access vba 中获取登录用户名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
有没有办法为 MS Access 获取当前的 Active Directory 用户?
我想通过 vba 在 access.这样做的最佳方法是什么?
I want to get the name of the logged-in User via vba in access. What is the best way to do this?
此问题的重复项:
- 是MS Access 有没有办法获取当前的 Active Directory 用户?
- 使用 VB6,如何在 Windows XP 上获取当前用户和域?
- 如何我可以在 Access VBA 中获取当前登录的 Windows 用户吗?
- Excel 2007 VBA 和 WMI - 当前域用户
推荐答案
Public Declare Function GetUserName Lib "advapi32.dll"
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
....
Dim strLen As Long
Dim strtmp As String * 256
Dim strUserName As String
strLen = 255
GetUserName strtmp, strLen
strUserName = Trim$(TrimNull(strtmp))
原来之前有人问过这个问题:如何在 Access VBA 中获取当前登录的 Windows 用户?
Turns out question has been asked before: How can I get the currently logged-in windows user in Access VBA?
这篇关于如何在 Access vba 中获取登录用户名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文