CSDN博客

img tanaya
博客专家

写了个函数,获取当前登录系统的用户名

发表于2004/9/27 15:14:00  1909人阅读

分类: >> VB6

今天要在工程中用到这个,顺便写了下,方便使用,源代码如下:

Option Explicit

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As

Long
Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long


Public Function GetSysLoggedUserName() As String
   Dim buf As String * 20
   If GetUserName(buf, 20)=1 Then
      GetSysLoggedUserName=Left$(buf,lstrlenW(StrPtr(buf)))
      Exit Function
   End If
   GetSysLoggedUserName=""
End Function

'-------------------------------------------
' 转载请注明出处
' 作者:唐细刚
' 邮箱:tanaya@163.com
'-------------------------------------------

阅读全文
0 0

相关文章推荐

img
取 消
img