| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 12031 人关注过本帖, 4 人收藏
标题:vb轻松获取计算机名,用户名 域名
取消只看楼主 加入收藏
心中有剑
Rank: 2
等 级:新手上路
威 望:5
帖 子:611
专家分:0
注 册:2007-5-18
收藏(4)
 问题点数:0 回复次数:4 
vb轻松获取计算机名,用户名 域名
以前都用api做,后来发现,不用api也很轻松搞定
Dim a As Object
Set a = CreateObject("Wscript.Network")
Print a.ComputerName
Print a.UserName
Print a.UserDomain
搜索更多相关主题的帖子: 域名 计算机 用户名 Print api 
2007-08-09 09:16
心中有剑
Rank: 2
等 级:新手上路
威 望:5
帖 子:611
专家分:0
注 册:2007-5-18
收藏
得分:0 

我直接调用他的,要不就是他封装的问题了!


2007-08-09 09:32
心中有剑
Rank: 2
等 级:新手上路
威 望:5
帖 子:611
专家分:0
注 册:2007-5-18
收藏
得分:0 

本机ip吗?其实不是很难的!


2007-08-10 09:51
心中有剑
Rank: 2
等 级:新手上路
威 望:5
帖 子:611
专家分:0
注 册:2007-5-18
收藏
得分:0 
Private Sub Command1_Click()
MsgBox strGetIpAdress
End Sub
Private Function strGetIpAdress() As String
Dim wsShell, re, myIp, r, strLine
Set wsShell = CreateObject("WScript.Shell")
Set re = CreateObject("vbScript.RegExp")
re.Pattern = "IP Address"
Set myIp = wsShell.Exec("ipconfig /all")
While Not myIp.StdOut.AtEndOfStream
strLine = myIp.StdOut.ReadLine()
r = re.Test(strLine)
If r Then
strGetIpAdress = Mid(strLine, InStrRev(strLine, ":") + 1)
End If
Wend
End Function

2007-08-10 10:15
心中有剑
Rank: 2
等 级:新手上路
威 望:5
帖 子:611
专家分:0
注 册:2007-5-18
收藏
得分:0 

Private Sub Command1_Click()
'IP 是ip地址
'Phy 是 mac地址
'Host 是 主机名
'DNS 是 dns
'Def 是缺省网关
'Sub 是 子网掩码

MsgBox strGetIpAdress("Sub")
End Sub
Private Function strGetIpAdress(InIp) As String
Dim wsShell, re, myIp, r, strLine
Set wsShell = CreateObject("WScript.Shell")
Set re = CreateObject("vbScript.RegExp")
re.Pattern = InIp
Set myIp = wsShell.Exec("ipconfig /all")
While Not myIp.StdOut.AtEndOfStream
strLine = myIp.StdOut.ReadLine()
r = re.Test(strLine)
If r Then
strGetIpAdress = Mid(strLine, InStrRev(strLine, ":") + 1)
End If
Wend
End Function

传参数注意大小写就可以了!


2007-08-10 10:36
快速回复:vb轻松获取计算机名,用户名 域名
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015222 second(s), 8 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved