How to get unique machine signature without WMI?

社会主义新天地 提交于 2019-12-22 10:09:53

问题


I know that a question has already been asked about generating a unique ID for a machine but my question is slightly different.

I want to know whether there are any other methods (API calls?) to get hardware information and NOT use WMI. I understand from MSDN that WMI is introduced in Win2000 so it doesnt seem to be available in Win98. I have an application that has to run even on Win98 (I know it sucks but what can you do?) and still get hold of hardware information.


回答1:


I've done this several times for licensing projects. For the hard drive serial number use:

private static extern long GetVolumeInformation(string PathName, StringBuilder VolumeNameBuffer, UInt32 VolumeNameSize, ref UInt32 VolumeSerialNumber, ref UInt32 MaximumComponentLength, ref UInt32 FileSystemFlags, StringBuilder FileSystemNameBuffer, UInt32 FileSystemNameSize);

Use the VolumeSerialNumber that is returned by the function.

Also, you may have thought about using the Windows Product ID (Located at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId). Be careful, a large number of Windows XP users have pirated copies and share the same product keys.




回答2:


You can combine different hardware information in order to create a unique key.

For example, CPU ID, MAC address etc etc. You retrieve them, combine them, encrypt them and you have a unique representation of the hardware setup of this machine.

Try googling about the subject: how to read hardware information.

From what I can see there is a very useful post in CodeProject: How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...).




回答3:


Look through the WinAPI's kernel32 and user32 library. It has all sorts of goodies like EnumDisplayDevices, GetLogicalDrives, GlobalMemoryStatus, GetVolumeInformation, etc, etc. I Like to use PInvoke to browse the API since it gives me the C# wrapper code - but MSDN will have it all as well in the Windows SDK.

@novatrust's answer regarding the hard drive serial is a good one - but can be combined with more. I've provided the GetVolumeInformation API link to pinvoke above, but a simple Google should work as well.



来源:https://stackoverflow.com/questions/872385/how-to-get-unique-machine-signature-without-wmi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!