python get registry infomation

来源:互联网 发布:网络攻击实时 编辑:程序博客网 时间:2024/06/07 02:44
MRAB schrieb:> Jorge wrote:>> I need to know how to get the hardware serial number of a hard disk in >> python.>>> For Windows, see http://www.daniweb.com/forums/thread187326.htmlThis recipe uses the function GetVolumeInformation(), which does notreturn the hardware serial number. From the microsoft documentation:  This function returns the volume serial number that the operating  system assigns when a hard disk is formatted. To programmatically  obtain the hard disk's serial number that the manufacturer assigns,  use the Windows Management Instrumentation (WMI) Win32_PhysicalMedia  property SerialNumber.The WMI method is e.g. described here:http://www.velocityreviews.com/forums/t359670-wmi-help.htmlimport wmic = wmi.WMI()for pm in c.Win32_PhysicalMedia():     print pm.Tag, pm.SerialNumberor to retrieve the serial number for the installation drive:serial = c.Win32_PhysicalMedia(["SerialNumber"], Tag=r"\\.\PHYSICALDRIVE0")[0].SerialNumber.strip()Regards,Dietmar


http://mail.python.org/pipermail/python-list/2002-August/735262.html

 

 

原创粉丝点击