读书人

vb 中怎么获得计算机的名字

发布时间: 2012-03-18 13:55:39 作者: rapoo

vb 中如何获得计算机的名字?
vb 中如何获得计算机的名字?

[解决办法]
使用winsock组件

Winsock1.LocalHostName
[解决办法]
Public Declare Function GetComputerName Lib "kernel32 " Alias "GetComputerNameA " (ByVal lpBuffer As String, nSize As Long) As Long

Dim strGetBuf As String * 255
dim strComputerName as string
strGetBuf = Space(255)
Call GetComputerName(strGetBuf, Len(strGetBuf))
strComputerName = Left(strGetBuf, Len(Trim(strGetBuf)) - 1)

[解决办法]
Private Declare Function GetComputerName Lib "kernel32.dll " Alias "GetComputerNameA " (ByVal lpBuffer As String, ByRef nSize As Long) As Long

Private Sub Form_Load()
Dim strname As String * 255
GetComputerName strname, 255
Debug.Print Left(strname, InStr(strname, Chr(0)) - 1)
End Sub

读书人网 >VB

热点推荐