wmivb.net的简单介绍

如何在VB中获得用户的IP地址啊,请指教 0Private Sub Form_Load()
Dim Cpu, Mer, Disk, Mac, Ip, DiskSerial, PCName
strComputer = "."
Cpu = ""
Mer = ""
Disk = ""
Mac = ""
Ip = ""
DiskSerial = ""
PCName = ""
'密码初始化标签
TePs.Text = ""
'获得CPU信息
Set objWMIService = GetObject("winmgmts:\\"strComputer)
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem In colItems
Cpu = objItem.Name
Next
TeCpu.Text = Trim(Cpu)
'获得内存信息
Set wbemObjectSet = objWMIService.InstancesOf("Win32_LogicalMemoryConfiguration") 'Win32_LogicalMemoryConfigurationWin32_PhysicalMemory
For Each wbemObject In wbemObjectSet
Mer1 = wbemObject.TotalPhysicalMemory '"KB"
Next
Mer = Int(((CLng(Mer1)) / 1024 * 10) / 10)
TeMer.Text = CStr(Mer)"MB"
'获得硬盘信息
Set wbemObjectSet = objWMIService.InstancesOf("Win32_DiskDrive")
For Each wbemObject In wbemObjectSet
Disk = wbemObject.Model
Next
TeDisk.Text = Disk
Set wbemObjectSet = objWMIService.InstancesOf("Win32_DiskDrive")
For Each wbemObject In wbemObjectSet
DiskSerial = wbemObject.Signature
Next
TeHd_serial.Text = DiskSerial
'获得MAC信息
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each objItem In colItems
Mac = Mac""objItem.macaddress
Next
TeMac.Text = Replace(Trim(Mac), ":", "-")
'获得电脑名称
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each objItem In colItems
PCName = objItem.DNSHostName
Next
TePcName.Text = PCName
strComputer = "."
Set objWMI = GetObject("winmgmts://"strComputer"/root/cimv2")
Set colIP = objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each Ip In colIP
If Not IsNull(Ip.ipaddress) Then
For I = LBound(Ip.ipaddress) To UBound(Ip.ipaddress)
'Mac = Ip.macaddress(I)objObject.DNSHostName
If Ip.ipaddress(I) = "0.0.0.0" Then
Else
TeIp.Text = Trim(TeIp.Text""Ip.ipaddress(I))
End If
'MsgBox "IP 地址:"IP.ipaddress(I)Chr(10)_
"网卡类型:"IP.Description(I)Chr(10)_
"网卡地址:"IP.macaddress(I)
Next
End If
Next
'Set wbemObjectSet = objWMIService.InstancesOf("Win32_NetworkAdapterConfiguration")
'For Each wbemObject In wbemObjectSet
' Mac = wbemObject.MACAddress
'Next
'TeMac.Text = Mac
'获得ip 及电脑名称信息
'Set winIP = GetObject("Win32_NetworkAdapterConfiguration") 'CreateObject("MSWinsock.Winsock")
'TeIp.Text = winIP.localip
'TePcName.Text = winIP.LocalHostName
End Sub
用vb.net如何取得mac地址?这是C#的,你可以转换一下
using System.Management;
//获取网卡的系列号
private static string GetMacAddress()
{
string ret = "";
try
{
ManagementClass cimobject = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = cimobject.GetInstances();
if (moc.Count == 0)
return "";
else
{
foreach (ManagementObject mo in moc)
{
if ((bool)mo["IPEnabled"] == true)
{
ret = (string)mo.Properties["MacAddress"].Value;
break;
}
}
}
}
catch
{
ret = "";
}
return ret;
}
VB.NET,部分机器获取不了CPU号(高分急用)VB wmivb.net我不熟,下面是用汇编写wmivb.net的,我运行过可以的 。
//--------------------------------
.model small
.586
.stack
.code
idstring db 49 dup('$')
start:
mov ax,@code
mov ds,ax
lea di,idstring
mov eax,80000002h
cpuid
mov dword ptr [di],eax
mov dword ptr [di 4],ebx
mov dword ptr [di 8],ecx
mov dword ptr [di 12],edx
mov eax,80000003h
cpuid
mov dword ptr [di 16],eax
mov dword ptr [di 20],ebx
mov dword ptr [di 24],ecx
mov dword ptr [di 28],edx
mov eax,80000004h
cpuid
mov dword ptr [di 32],eax
mov dword ptr [di 36],ebx
mov dword ptr [di 40],ecx
mov dword ptr [di 44],edx
mov ah,09h
lea dx,idstring
int 21h
mov ah,4ch
int 21h
end start
//-------------------------------------------------------
程序确实可以执行,输出CPU的ID等信息 。
注意wmivb.net:DOS下或MS-DOS下使用 。
C#或者vb.net有办法进入ring0层吗?Vista由于使用了更严格的权限管理体系,在一般用户(没有提升到管理员之前都是一般用户,即便你使用Administrator登录)上下文下 , 你没有办法获得CPU使用率 。建议的解决办法是在程序启动时提升权限,具体可以通过修改manifast文件来实现 。右键点击启动的哪个Project,选择添加项目,添加manifast文件 。在生成的manifast文件中很容易找到关于权限的注释 , 按照注释操作即可 。
提升权限后获得CPU占用率建议使用System.Diagnostics.PerformanceCounter是不是WMI,因为相对于前者 , WMI的数据有很大的延时 , 并不可靠 。
(VS.80).aspx
这里有完整的例子:)
Ps:楼上诋毁Vista的理由很汗 。
VB.Net (VB2010)怎么使用WMI来获取CPU型号?Imports System
Imports System.Management
Module Module1
Sub Main()
Dim scope As New ManagementScope("\\.\root\cimv2")
scope.Connect()
Dim objectQuery As New ObjectQuery("SELECT * FROM Win32_Processor")
Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
Dim cpu As ManagementObject
For Each cpu In searcher.Get()
Console.WriteLine("Processor: "cpu("Name"))
Console.WriteLine("Manufacturer: "cpu("Manufacturer"))
Console.WriteLine("Clock frequency: "cpu("MaxClockSpeed")" MHz")
Console.WriteLine("NumberOfLogicalProcessors: "cpu("NumberOfLogicalProcessors"))
Console.WriteLine("NumberOfCores: "cpu("NumberOfCores"))
Console.WriteLine()
Next cpu
Console.WriteLine()
Console.WriteLine("Press any key to quit")
Console.ReadKey()
End Sub
End Module
vb.net如何获取当前进程的cpu和内存使用率?使用wmi
类“Win32_Processor”中LoadPercentage属性为当前wmivb.net的cpu使用率
示例代码wmivb.net: Private Sub Timer1_Timer()
Dim WMI服务 As Object
Dim 对象 As Object
Dim 子对象 As Object
Dim 电脑名 As String
Dim 刷新 As Long
刷新 = 0
电脑名 = "." '表示本地计算机
Set WMI服务 = GetObject("winmgmts://"电脑名"/root/cimv2")
Set 对象 = WMI服务.InstancesOf("Win32_Processor")
Me.CurrentX = 0
Me.CurrentY = 0
For Each 子对象 In 对象
If 刷新 = 0 Then
刷新 = 1
Me.Cls
End If
Me.Print 子对象.Name"["子对象.CurrentClockSpeed"Hz] 使用率:"_
子对象.LoadPercentage"%"
Next
End Sub
【wmivb.net的简单介绍】关于wmivb.net和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读