求教:VB如何获取当前系统用户帐号
也就是,系统有2个帐号,分别是管理员和访客,如何用VB实现程序可以知道
当前用户是管理员或是访客呢?
环境:WINDOWS XP SP2
VB6
[解决办法]
使用API: GetUserName
[解决办法]
http://www.popbb.net/soft/t46/20074232.shtml
[解决办法]
Private Declare Function GetUserName Lib "advapi32.dll " Alias "GetUserNameA " (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Load()
Dim strUserName As String
'Create a buffer
strUserName = String(100, Chr$(0))
'Get the username
GetUserName strUserName, 100
'strip the rest of the buffer
strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
MsgBox "Hello " + strUserName
End Sub