Selasa, 09 Juni 2015

VB 6.0 - Fungsi unuk Mengambil Nama User dan Nama Komputer




Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function Get_UName()as StringDim sUser As StringDim sComputer As StringDim lpBuff As String * 1024
  'Get the Login User NameGetUserName lpBuff, Len(lpBuff)sUser = Left$(lpBuff, (InStr(1, lpBuff, vbNullChar)) - 1)lpBuff = ""
  'Get the Computer NameGetComputerName lpBuff, Len(lpBuff)sComputer = Left$(lpBuff, (InStr(1, lpBuff, vbNullChar)) - 1)lpBuff = ""
  Get_UName = "Login User: " & sUser & vbCrLf & _"Computer Name: " & sComputer
End Function

0 komentar:

Posting Komentar