Parsi Coders
Get the name of this computer - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: Visual Basic Programming (http://parsicoders.com/forumdisplay.php?fid=39)
+---- انجمن: Visual Basic 6 (http://parsicoders.com/forumdisplay.php?fid=44)
+---- موضوع: Get the name of this computer (/showthread.php?tid=2098)



Get the name of this computer - Amin_Mansouri - 04-15-2012

کد:
Public Declare Function GetLocalComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nsize As Long) As Long
    Public Function GetComputerName() As String
    '==================================
    '==================================
    Dim strComputerName As String
    Dim lngResult As Long
    '-- Set up buffer.
    strComputerName = String$(255, 0)
    '-- Make the call.
    lngResult = GetLocalComputerName(strComputerName, 255)
    '-- Clean up and assign the value.
    If lngResult = 1 Then GetComputerName = Left$(strComputerName, InStr(1, strComputerName, vbNullChar) - 1)
    End Function