Windows API:GetUserName的用法

 

 

说明:取得当前用户的名字

库名:advapi32.dll

分类:硬件与系统函数

实例:获得当前windows登录的用户名

Option Explicit

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

Private Sub Form_Load()
  Dim str As String
  Dim cnt As Long
  Dim dl As Long
  Dim CurUser As String
  cnt = 199
  s = String$(200, 0)
  dl = GetUserName(str, cnt)
  Debug.Print dl <> 0, "当前用户=" & Left$(str, cnt), "当前用户="
End Sub

posted on 2011-07-18 09:57  刘正权的博客  阅读(531)  评论(0编辑  收藏  举报