如何在VB中为64位/Access 2013检索Windows用户ID? [英] How to retrieve Windows userID in VB for 64-bit/Access 2013?

查看:119
本文介绍了如何在VB中为64位/Access 2013检索Windows用户ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取代码以在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.

我已经尝试过中建议的解决方案要在Access vba中获得登录用户的名称?,但是显然这在我的64位计算机上不起作用.我还试图找出如何在 http:上集成信息的方法: //msdn.microsoft.com/zh-CN/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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆