Office中国论坛/Access中国论坛

标题: 请教: [打印本页]

作者: vvvtian    时间: 2004-7-14 04:30
标题: 请教:
EXCEL中如何用VBA取得系统信息?如用户名等。谢谢!
作者: ui    时间: 2004-7-14 17:29
使用API来做
作者: hzg7818    时间: 2004-7-15 03:56
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As LongFunction UserName()

    Dim s As String, cnt As Long, dl As Long

    cnt& = 199

    s = String(200, 0)

    dl = GetUserName(s, cnt)

    UserName = Left(s, cnt)

End FunctionSub test()

    MsgBox UserName

End Sub返回当前用户名
作者: vvvtian    时间: 2004-7-15 04:08
谢谢版主!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3