如何在 VB 中为 64 位/Access 2013 检索 Windows 用户 ID? [英] How to retrieve Windows userID in VB for 64-bit/Access 2013?
问题描述
我需要获取代码以在 64 位系统上的 VB(对于 Access 2013)中检索当前会话的 Windows 用户 ID.
I need to get code to retrieve the Windows userID for the current session in VB (for Access 2013) on a 64-bit system.
我已经尝试了 How在 Access vba 中获取登录用户名?,但显然这在我的 64 位机器上不起作用.我还试图弄清楚如何整合 http://msdn.microsoft.com/en-us/library/office/gg278832.aspx,但我想不通.
I've tried the solution suggested at How to get logged-in user's name in Access vba?, but apparently this doesn't work on my 64-bit machine. I've also tried to figure out how to integrate the info at http://msdn.microsoft.com/en-us/library/office/gg278832.aspx, but I can't figure it out.
我是一名 NOVICE VB 程序员,所以我真的需要实际的代码来做到这一点.(在我看到代码后,我 [可能] 可以弄清楚代码是如何以及为什么这样做的,但此时我无法从头开始.)
I am a NOVICE VB programmer, so I really need the actual code to do this. (I can [probably] figure out how & why the code does what it does after I see it, but I can't come up with it from scratch at this point.)
我希望这个答案对其他人也有帮助.
I'm hoping this answer will be helpful to others, too.
非常感谢!
阿罗哈,-pt
推荐答案
您链接到的答案适用于 32 位版本的访问.对于 64 位版本,您需要使用指针安全签名:
The answer you linked to works on a 32 bit version of access. For 64 bit versions, you need to use a pointer-safe signature:
Private Declare PtrSafe Function GetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As LongPtr) As Long
(它可能适用于 nSize As Long
- 我手头没有 64 位访问权限)
(it might work with nSize As Long
- I don't have a 64-bit access at hand)
这篇关于如何在 VB 中为 64 位/Access 2013 检索 Windows 用户 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!