Private Function CpuId() As String Dim computer As String Dim wmi As Variant Dim processors As Variant Dim cpu As Variant Dim cpu_ids As String computer = "." Set wmi = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\" & _ computer & "\root\cimv2") Set processors = wmi.ExecQuery("Select * from " & _ "Win32_Processor") For Each cpu In processors cpu_ids = cpu_ids & ", " & cpu.ProcessorID Next cpu If Len(cpu_ids) > 0 Then cpu_ids = Mid$(cpu_ids, 3) CpuId = cpu_ids End Function Cara ke 2 Command1_Click() Dim wmiLocator As New WbemScripting.SWbemLocator Dim wmiService As WbemScripting.SWbemServices Dim wmiProc As WbemScripting.SWbemObject ' 'Establish a connection to WMI Set wmiService = wmiLocator.ConnectServer ' 'Enumerate the processor IDs For Each wmiProc In wmiService.InstancesOf("Win32_Processor") MsgBox wmiProc.ProcessorID Next End sub
Thursday, February 28, 2013
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment