首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

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

2012-03-18 
vb 中如何获得计算机的名字?vb中如何获得计算机的名字?[解决办法]使用winsock组件Winsock1.LocalHostName[

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

热点排行