- UID
- 286196
- 帖子
- 1238
- 主題
- 192
- 精華
- 0
- 積分
- 2485
- 楓幣
- 5367
- 威望
- 1944
- 存款
- 0
- 贊助金額
- 1950
- 推廣
- 0
- GP
- 230
- 閱讀權限
- 150
- 在線時間
- 1075 小時
- 註冊時間
- 2020-7-11
- 最後登入
- 2024-12-23
|
本帖最後由 yuanzhan 於 2021-9-26 11:07 編輯
'cpu序號
Public Function GetCpuID() As String
Try
Dim cpuInfo As String = ""
Dim moc As ManagementObjectCollection = New ManagementClass("Win32_Processor").GetInstances
Dim mo As ManagementObject
For Each mo In moc
cpuInfo = mo.Properties.Item("ProcessorId").Value.ToString
Next
moc = Nothing
Return cpuInfo
CpuID = cpuInfo
Catch
Return "unknow"
End Try
End Function '硬碟系列號
Public Function GetDiskID() As String
Try
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
Dim strHardDiskID As String = ""
For Each mo As ManagementObject In searcher.Get()
strHardDiskID = mo.Properties("SerialNumber").Value.ToString
strHardDiskID = strHardDiskID.Replace(" ", "")
Exit For
Next
Return strHardDiskID
Catch
Return "unknow"
End Try
End Function '硬碟型號
Public Function GetDiskModel() As String
Try
Dim HDModel As String = ""
Dim moc As ManagementObjectCollection = New ManagementClass("Win32_DiskDrive").GetInstances
Dim mo As ManagementObject
For Each mo In moc
HDModel = mo.Properties("Model").Value.ToString
Next
moc = Nothing
Return HDModel
DiskID = HDModel
Catch
Return "unknow"
End Try
End Function 'CPU
Function GetDiskModel_1() As String
Try
Dim HDModel As String = ""
Dim mc As ManagementClass = New ManagementClass("Win32_DiskDrive")
Dim moc As ManagementObjectCollection = mc.GetInstances()
For Each mo As ManagementObject In moc
HDModel = mo.Properties("Model").Value.ToString
'HDModel = HDModel.Replace(" ", "")
Exit For
Next
moc = Nothing
mc = Nothing
Return HDModel
Catch
Return "unknow"
End Try
End Function '主機板
Function GetmainboardID() As String
Try
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("Select * FROM Win32_BaseBoard")
Dim strmainboardID As String = ""
For Each mo As ManagementObject In searcher.Get()
strmainboardID = mo.Properties("SerialNumber").Value.ToString
strmainboardID = strmainboardID.Replace(" ", "")
Exit For
Next
Return strmainboardID
Catch
Return "unknow"
End Try
End Function 'ip地址
Public Function GetIPAddress() As String
Try
Dim st As String = ""
Dim moc As ManagementObjectCollection = New ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances
Dim mo As ManagementObject
For Each mo In moc
If CBool(mo.Item("IPEnabled")) Then
Dim ar As Array = DirectCast(mo.Properties.Item("IpAddress").Value, Array)
st = ar.GetValue(0).ToString
Exit For
End If
Next
moc = Nothing
Return st
IpAddress = st
Catch
Return "unknow"
End Try
End Function 'mac地址
Public Function GetMacAddress() As String
Try
Dim mac As String = ""
Dim moc As ManagementObjectCollection = New ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances
Dim mo As ManagementObject
For Each mo In moc
If CBool(mo.Item("IPEnabled")) Then
mac = mo.Item("MacAddress").ToString
Exit For
End If
Next
moc = Nothing
Return mac
MacAddress = mac
Catch
Return "unknow"
End Try
End Function '系統類型
Public Function GetSystemType() As String
Try
Dim st As String = ""
Dim moc As ManagementObjectCollection = New ManagementClass("Win32_ComputerSystem").GetInstances
Dim mo As ManagementObject
For Each mo In moc
st = mo.Item("SystemType").ToString
Next
moc = Nothing
Return st
SystemType = st
Catch
Return "unknow"
End Try
End Function '内存空間
Public Function GetTotalPhysicalMemory() As String
Try
Dim st As String = ""
Dim moc As ManagementObjectCollection = New ManagementClass("Win32_ComputerSystem").GetInstances
Dim mo As ManagementObject
For Each mo In moc
st = mo.Item("TotalPhysicalMemory").ToString
Next
moc = Nothing
Return st
TotalPhysicalMemory = st
Catch
Return "unknow"
End Try
End Function '系統用戶名
Public Function GetUserName() As String
Try
Dim st As String = ""
Dim moc As ManagementObjectCollection = New ManagementClass("Win32_ComputerSystem").GetInstances
Dim mo As ManagementObject
For Each mo In moc
st = mo.Item("UserName").ToString
Next
moc = Nothing
Return st
LoginUserName = st
Catch
Return "unknow"
End Try
End Function
如何使用就看各位了,我這邊僅此提供模塊
|
|