Posted By

sekihin on 06/22/09


Tagged

vb6


Versions (?)

取得计算机名


 / Published in: Visual Basic
 

  1. Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  2.  
  3. 'コンピュータ名の取得
  4. '
  5. Private Function gfGetComputerName() As String
  6. Dim lngRetValue As Long
  7. Dim CompName As String * 128
  8. Dim CompNameSize As Long
  9.  
  10. CompNameSize = Len(CompName)
  11. lngRetValue = GetComputerName(CompName, CompNameSize)
  12. If lngRetValue <> 0 Then
  13. gfGetComputerName = Left$(CompName, InStr(CompName, vbNullChar) - 1)
  14. End If
  15. gfGetComputerName = LeftQ(gfGetComputerName, 15)
  16.  
  17. End Function

Report this snippet  

You need to login to post a comment.