[pre lang="VB.net" line="1"]Public Class Form1
Public Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer
Dim iReturn As Integer
Dim userName As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
userName = Space(100)
iReturn = GetUserNameA(userName, 50)
Label1.Text = userName
End Sub
End Class[/pre]
如果把[pre lang="VB.net" line="1"]Public Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer[/pre]改为[pre lang="VB.net" line="1"]Public Declare Function GetUserName Lib "advapi32.dll" (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer[/pre]却不能获取当前登陆用户的名称,而且不报错。
我的言论只代表我个人的观点,不代表雇主及/或任何第三方的立场。
Opinions expressed are solely my own and do not express the views or opinions of my employer and/or any third parties. 捐赠 | GitHub