求得机器名

原文链接: http://www.cnblogs.com/qiyuan/archive/2005/10/09/250886.html

'*************************
'求得机器名gComputerName
'去掉字符 NONAME = !%^*+-^()&?/|\~><':;}[{] ,."
'得到临时变量名gTempName
Public Sub GetComputerNameStr()

    Dim strtmp As String * 255
    Dim lok As Long, strTmp1 As String
   
    Const NONAME = "!%^*+-^()&?/|\~><':;}[{] ,."
   
    lok = GetComputerName(strtmp, 255)
    gComputerName = Left(strtmp, InStr(strtmp, Chr(0)) - 1)
   
    For lok = 1 To Len(gComputerName)
        strTmp1 = Mid(gComputerName, lok, 1)
        If strTmp1 = Chr(34) Then
            strTmp1 = "_"
        Else
            If InStr(NONAME, strTmp1) > 0 Then strTmp1 = "_"
        End If
        gTempName = gTempName & strTmp1
    Next lok
  
End Sub

转载于:https://www.cnblogs.com/qiyuan/archive/2005/10/09/250886.html

你可能感兴趣的:(求得机器名)