自动修改计算机用户名,用vb语言来写。。
答案:2 悬赏:30 手机版
解决时间 2021-02-12 00:11
- 提问者网友:捧腹剧
- 2021-02-11 04:58
自动修改计算机用户名,比如:比如输入10号机子,使得用户名和计算机名都变成ks10用vb语言来写。。
最佳答案
- 五星知识达人网友:渊鱼
- 2021-02-11 06:06
声明GetComputerName
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA"
(ByVal lpBuffer As String, nSize As Long) As Long
声明SetComputerName
Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA"
(ByVal lpComputerName As String) As Long
’定义一个获取计算机名字的函数
Public Function GetCName(CName) As Boolean
Dim sComputerName As String 计算机的名字
Dim lComputerNameLen As Long 计算机名字的长度
Dim lResult As Long GetComputerName的返回值
Dim RV As Boolean GetCName返回值,若为TRUE则表示操作成功
lComputerNameLen = 256
sComputerName = Space(lComputerNameLen)
lResult = GetComputerName(sComputerName, lComputerNameLen)
If lResult <> 0 Then
CName = Left$(sComputerName, lComputerNameLen)
RV = True
Else
RV = False
End If
GetCName = RV
End Function
定义一个修改计算机名字的函数
Public Function SetCName(CName As String) As Boolean
Dim lResult As Long
Dim RV As Boolean
lResult = SetComputerName(CName)
If lResult <> 0 Then
RV = True 修改成功
Else
RV = False
End If
SetCName =RV
End Function
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA"
(ByVal lpBuffer As String, nSize As Long) As Long
声明SetComputerName
Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA"
(ByVal lpComputerName As String) As Long
’定义一个获取计算机名字的函数
Public Function GetCName(CName) As Boolean
Dim sComputerName As String 计算机的名字
Dim lComputerNameLen As Long 计算机名字的长度
Dim lResult As Long GetComputerName的返回值
Dim RV As Boolean GetCName返回值,若为TRUE则表示操作成功
lComputerNameLen = 256
sComputerName = Space(lComputerNameLen)
lResult = GetComputerName(sComputerName, lComputerNameLen)
If lResult <> 0 Then
CName = Left$(sComputerName, lComputerNameLen)
RV = True
Else
RV = False
End If
GetCName = RV
End Function
定义一个修改计算机名字的函数
Public Function SetCName(CName As String) As Boolean
Dim lResult As Long
Dim RV As Boolean
lResult = SetComputerName(CName)
If lResult <> 0 Then
RV = True 修改成功
Else
RV = False
End If
SetCName =RV
End Function
全部回答
- 1楼网友:傲气稳了全场
- 2021-02-11 07:11
private sub command1_click()
dim a as object
set a = createobject("wscript.network")
print a.computername
print a.username
print a.userdomain
end sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯