from tkinter import *
import wmi
import socket
c = wmi.WMI()
def hard_id():
for physical_disk in c.Win32_DiskDrive():
var = physical_disk.SerialNumber
t.insert(‘insert‘, "硬盘序列号:\n")
t.insert(‘insert‘, var)
def cpu_id():
for cpu in c.Win32_Processor():
var = cpu.ProcessorId.strip()
t.insert(‘insert‘, "\n")
t.insert(‘insert‘, "CPU序列号:\n")
t.insert(‘insert‘, var)
def board_id():
for board_id in c.Win32_BaseBoard():
var = board_id.SerialNumber
t.insert(‘insert‘, "\n")
t.insert(‘insert‘, "主板序列号:\n")
t.insert(‘insert‘, var)
def mac_id():
mac_all=[]
for mac in c.Win32_NetworkAdapter():
mac_all.append(mac.MACAddress)
var = mac_all[1]
t.insert(‘insert‘, "\n")
t.insert(‘insert‘, "mac地址: \n " )
t.insert(‘insert‘, var)
def bios_id():
for bios_id in c.Win32_BIOS():
var=bios_id.SerialNumber.strip()
t.insert(‘insert‘, "\n")
t.insert(‘insert‘, "bios序列号:\n")
t.insert(‘insert‘, var)
def my_id():
for bios_id in c.Win32_BIOS():
bios_id.SerialNumber.strip()
var1 = socket.getfqdn(socket.gethostname( ))
var = socket.gethostbyname(var1)
t.insert(‘insert‘, "\n")
t.insert(‘insert‘, "电脑系统名称:\n")
t.insert(‘insert‘, var1)
t.insert(‘insert‘, "\n")
t.insert(‘insert‘, "ip地址:\n")
t.insert(‘end‘, var)
win=Tk()
win.title(‘王sir电脑信息查看工具,微信:dvs909‘)
win.geometry(‘400x200‘)
t = Text(win,width=20,height=2.5)
t.pack(side="left", fill="both",padx=1,pady=10)
btn = Button(win, text=‘获取硬盘序列号‘, width = 12, height = 1,command=hard_id)
btn.pack(side=TOP)
win.geometry(‘400x200‘)
btn2 = Button(win, text=‘获取CPU序列号‘,width = 12, height = 1,command=cpu_id)
btn2.pack(side=TOP)
btn3 = Button(win, text=‘获取主板序列号‘,width = 12, height = 1,command=board_id)
btn3.pack(side=TOP)
btn4 = Button(win, text=‘获取mac地址‘, width = 12, height = 1,command=mac_id)
btn4.pack(side=TOP)
btn5 = Button(win, text=‘获取bios序列号‘,width = 12, height = 1,command=bios_id)
btn5.pack(side=TOP)
btn6 = Button(win, text=‘获取ip及系统名‘,width = 12, height = 1,command=my_id)
btn6.pack(side=TOP)
mainloop()