怎样设置计算机名称?

hld168 2003-04-09 01:43:03
怎么写,

api
...全文
63 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
饮水需思源 2003-04-09
  • 打赏
  • 举报
回复
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function ShowWindow Lib "USER32" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long


Public Function computerName() As String
Dim tmpstr As String
Dim l As Long
tmpstr = String(256, 0)
l = GetComputerName(tmpstr, 256)
computerName = Left$(tmpstr, InStr(tmpstr, Chr(0)) - 1)
cClientName = computerName
End Function
minajo21 2003-04-09
  • 打赏
  • 举报
回复
Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
Private Sub Form_Load()
Dim sNewName As String
'Ask for a new computer name
sNewName = InputBox("Please enter a new computer name.")
'Set the new computer name
SetComputerName sNewName
MsgBox "Computername set to " + sNewName
End Sub
lihonggen0 2003-04-09
  • 打赏
  • 举报
回复
声明:
Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
使用:
NewName = "Hello World"
SetComputerName NewName

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧