vb.net 取CPU型号和本地连接启用禁用的代码
求vb.net代码1.取CPU型号,不是CPUid,不是CPU序列号,是下图红色圈这种。2.下图,本地连接,本地连接2网络重启,启用,禁用。或者网络服务禁用启动。用途是重启网络。
谢谢大佬 Todd 发表于 2022-4-24 10:39
网络属性
用这个 Win32_NetworkAdapterConfiguration
勘误
应该是这个
PSComputerName : DESKTOP-MGDFEAP
Availability : 3
CpuStatus : 1
CurrentVoltage : 8
DeviceID : CPU0
ErrorCleared :
ErrorDescription :
LastErrorCode :
LoadPercentage : 4
Status : OK
StatusInfo : 3
AddressWidth : 64
DataWidth : 64
ExtClock : 100
L2CacheSize : 1536
L2CacheSpeed :
MaxClockSpeed : 2208
PowerManagementSupported : False
ProcessorType : 3
Revision :
SocketDesignation : U3E1
Version :
VoltageCaps :
__GENUS : 2
__CLASS : Win32_Processor
__SUPERCLASS : CIM_Processor
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_Processor.DeviceID="CPU0"
__PROPERTY_COUNT : 57
__DERIVATION : {CIM_Processor, CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemEleme
nt}
__SERVER : DESKTOP-MGDFEAP
__NAMESPACE : root\cimv2
__PATH : \\DESKTOP-MGDFEAP\root\cimv2:Win32_Processor.DeviceID="CPU0"
Architecture : 9
AssetTag : To Be Filled By O.E.M.
Caption : Intel64 Family 6 Model 158 Stepping 10
Characteristics : 252
ConfigManagerErrorCode :
ConfigManagerUserConfig :
CreationClassName : Win32_Processor
CurrentClockSpeed : 2208
Description : Intel64 Family 6 Model 158 Stepping 10
Family : 198
InstallDate :
L3CacheSize : 9216
L3CacheSpeed : 0
Level : 6
Manufacturer : GenuineIntel
Name : Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
NumberOfCores : 6
NumberOfEnabledCore : 6
NumberOfLogicalProcessors : 12
OtherFamilyDescription :
PartNumber : To Be Filled By O.E.M.
PNPDeviceID :
PowerManagementCapabilities :
ProcessorId : BFEBFBFF000906EA
Role : CPU
SecondLevelAddressTranslationExtensions : False
SerialNumber : To Be Filled By O.E.M.
Stepping :
SystemCreationClassName : Win32_ComputerSystem
SystemName : DESKTOP-MGDFEAP
ThreadCount : 12
UniqueId :
UpgradeMethod : 52
VirtualizationFirmwareEnabled : False
VMMonitorModeExtensions : False
Scope : System.Management.ManagementScope
Path : \\DESKTOP-MGDFEAP\root\cimv2:Win32_Processor.DeviceID="CPU0"
Options : System.Management.ObjectGetOptions
ClassPath : \\DESKTOP-MGDFEAP\root\cimv2:Win32_Processor
Properties : {AddressWidth, Architecture, AssetTag, Availability...}
SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers : {dynamic, Locale, provider, UUID}
Site :
Container :
需要什么属性 直接改
Sub CPU 属性()
For Each 序列 In GetObject("Winmgmts:").InstancesOf("Win32_Processor")
MsgBox "CPU 属性: " & CStr(序列.需要的属性)
Next
End Sub
本帖最后由 keeeeeen 于 2022-4-23 21:59 编辑
Todd 发表于 2022-4-23 18:58
PSComputerName : DESKTOP-MGDFEAP
Availability : ...
看到了,,,{:1_921:} Todd 发表于 2022-4-23 18:58
PSComputerName : DESKTOP-MGDFEAP
Availability : ...
太厉害了!{:1_921:}
网络部分呢?哪个属性 zhhmok 发表于 2022-4-24 09:17
太厉害了!
网络部分呢?哪个属性
这是CPU 部分
网络属性
用这个 Win32_NetworkAdapterConfiguration
class Win32_NetworkAdapter : CIM_NetworkAdapter
{
string AdapterType;
uint16 AdapterTypeID;
booleanAutoSense;
uint16 Availability;
string Caption;
uint32 ConfigManagerErrorCode;
booleanConfigManagerUserConfig;
string CreationClassName;
string Description;
string DeviceID;
booleanErrorCleared;
string ErrorDescription;
string GUID;
uint32 Index;
datetime InstallDate;
booleanInstalled;
uint32 InterfaceIndex;
uint32 LastErrorCode;
string MACAddress;
string Manufacturer;
uint32 MaxNumberControlled;
uint64 MaxSpeed;
string Name;
string NetConnectionID;
uint16 NetConnectionStatus;
booleanNetEnabled;
string NetworkAddresses[];
string PermanentAddress;
booleanPhysicalAdapter;
string PNPDeviceID;
uint16 PowerManagementCapabilities[];
booleanPowerManagementSupported;
string ProductName;
string ServiceName;
uint64 Speed;
string Status;
uint16 StatusInfo;
string SystemCreationClassName;
string SystemName;
datetime TimeOfLastReset;
}; Todd 发表于 2022-4-24 11:08
勘误
应该是这个
谢谢大佬{:1_893:}
学你查了一下,也验证了一下。
NetEnabled应该是有没有插网线或有没有连接WIFI,或有没有连接蓝牙
PhysicalAdapter应该是物理设备有没有启用 谢谢各路大佬,学习了{:1_893:}
一开始语句Dim colAdapters As New System.Management.ManagementObjectSearcher("Select * from Win32_NetworkAdapter where NetEnabled =ture")
不应该在colAdapters ,where..。导致没数据
Dim colAdapters As New System.Management.ManagementObjectSearcher("Select * from Win32_NetworkAdapter")
For Each Adapter As ManagementObject In colAdapters.Get
MsgBox(Adapter("DeviceId") & Adapter("NetEnabled") & Adapter("NAME") & Adapter("NetConnectionID") & Adapter("PhysicalAdapter"))
Next
才有数据。
页:
[1]