Jump to content

Recommended Posts

Hello,

 

I need some unique hardware ID code generator which will be a piece of Delphi code or some VCL library without any external dll's or libraries.

The idea is that I have all computers in my catalog by hardware id, and when a user has some requests, I find his client computer in my catalog and send him a repair script.

The main goal is to provide each client with a unique id across the entire system.

 

Thanks in advance for any tips or samples...

Share this post


Link to post

Hello,

 

I made my custom solution and I got the hardware fingerprint I wanted (for example, 1805-AD75-1308-150F) and it is definitely unique because I'm using 3-5 hardware components when I plan to generate this fingerprint.

 

This is a similar solution to popular DLL components, which return some code to represent a unique hardware id, but in my dev factory.

 

Thank you for all of the professional responses and information:-)

Share this post


Link to post

I'm using 3-5 hardware components

 

Maybe you mean that you use 3 to 5 devices in the computer to generate the fingerprint. If this is the case, then don't forget that the use may upgrade their hardware because of failure or just better performances. You may detect an unknown computer just because they replaced their Ethernet card (If you use the MAC address), hard disk serial or even Windows own MachineGUID. The computer may also be a virtual one running under VMWare, Hyper-V or another hypervisor. That the hardware is virtualized. Lot's of traps...

  • Like 1

Share this post


Link to post

The trick I believe Windows itself uses is to allow one or two failures of the hardware IDs that are collected and compared, to allow for replacement components.  Assuming you store and compare each ID separately, rather than hashing them all together. 

 

Also beware that some Ethernet MAC addresses are deliberately random, most new phones and Windows 10 (unless disabled), in an attempt to stop some web sites tracking you.  There is a bit in the MAC that indicates it is random.   Random IPv6 addresses often include the MAC, so are not really random atall.

 

Angus

 

Edited by Angus Robertson

Share this post


Link to post

Hey! We actually use the following code to get the system serial - maybe that can help:
 

function GetSystemSerial : string;
var FSWbemLocator : OLEVariant;
  FWMIService   : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject   : OLEVariant;
  oEnum         : IEnumvariant;
  iValue        : LongWord;
begin
     CoInitialize(nil);
     try
        result:='';
        FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');

        // ATT: we had a case, where on a Win2016 server, the system service failed to
        //      execute this command. Changing the service to a local user solved the problem.

        // There has been 2 cases where the WMI service was corrupted or was not running.
        // -> to check: enter WmiMgmt.msc in the console and right click on the local wmi - control -> Properties
        //    if an error occurs the repository seems to be corrupt
        // one time it helped to reset and rebuild the repository:
        // https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-rebuilding-the-wmi-repository/ba-p/373846
        try
           FWMIService   := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', '', '');
        except
              on e : Exception do
              begin
                   OutputDebugString(PChar('WMI service not properly running: '+e.Message+#13#10+
                     'https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-rebuilding-the-wmi-repository/ba-p/373846'));
                   raise;
              end;
        end;

        // todo: if we still support winxp this wmi class is not supported?!?
        FWbemObjectSet:= FWMIService.ExecQuery('SELECT UUID FROM Win32_ComputerSystemProduct','WQL',$00000020 {wbemFlagForwardOnly});
        oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
        if oEnum.Next(1, FWbemObject, iValue) = 0 then
           result:=String(FWbemObject.UUID);
     finally
       CoUninitialize;
     end;
end;

 

There is also another place where you could get some unique id:
 

// from http://www.nextofwindows.com/the-best-way-to-uniquely-identify-a-windows-machine
     with OpenHKLMReadOnly('SOFTWARE\Microsoft\Cryptography', True) do
     begin
          AktMachineGuid:=ReadString('', 'MachineGuid', '');
          Log('Machine guid: ' + AktMachineGuid);
          Free;
     end;

 

hope that helps!

 

kind regards

  Mike

  • Like 2

Share this post


Link to post
13 hours ago, mikerabat said:

MachineGuid

I've seen that change when the Windows license is changed.

Share this post


Link to post

First: how often does the license change? Never had any case like that... Even windows update did not change it...

 

Actually the articel that is referenced in the code has a few hints for such unique ID's.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×