basnet.bas

来自「常用基本函数库,也许你需要的正在其中!如果不做程序」· BAS 代码 · 共 25 行

BAS
25
字号
Attribute VB_Name = "basNet"
Option Explicit

Private Declare Function WNetGetUser Lib "mpr" Alias _
   "WNetGetUserA" (ByVal lpName As String, _
   ByVal lpUserName As String, lpnLength As Long) As Long

'
'  Returns the user name or "" if the
'  user is not logged on.
'
Public Function NetUserName() As String
   Dim i As Long
   Dim UserName As String * 255

   i = WNetGetUser("", UserName, 255)
   
   If i = 0 Then
      NetUserName = Left$(UserName, InStr(UserName, Chr$(0)) - 1)
   Else
      NetUserName = ""
   End If
   
End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?