views:

916

answers:

3

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.

A: 

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

For example, CPU ID, MAC address etc etc. You retrieve em, 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

Konstantinos
Thats exactly the question! *HOW* to get hold of this information?
Hemant
the example refers to .NET 2.0 which is OK for your Win98 requirement
Konstantinos
+1  A: 

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 http://pinvoke.net 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.

TheSoftwareJedi
+2  A: 

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

GetVolumeInformation

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 HKLM SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId). Be careful, a large number of Windows XP users have pirated copies and share the same product keys.

Robert Venables
MSDN online will tell you that GetVolumeInformation is only available from Windows 2000, but that's not true. Recent versions of the MSDN library content like to deny the existence of Windows 9x, but if you look in an old version of the MSDN library (I looked in the one that came with Visual Studio 2005) it shows that GetVolumeInformation *is* available in Windows 98.
RichieHindle