Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unique integer indentifier 1

Status
Not open for further replies.

GCTIberica

Programmer
Jun 20, 2003
30
ES
Does anyone know of a unique identifier that is an integer (not GUID) and is not system time?
 
GCTIberica,

Well, I suppose you could use the machine's MAC address, though that presumes the presence of a LAN card.

There's some sample code at and using it is fairly straight-forward:

Code:
uses MACAddress;

procedure TForm1.Button1Click(Sender: TObject);
var
   tma : tMacAddress;

begin

   tma := getMacAddress( 0 );
   edit1.Text := format( '%.2x-%.2x-%.2x-%.2x-%.2x-%.2x',
                        [ tma[0], tma[1], tma[2], tma[3], 
                          tma[4], tma[5] ] );

end;

This gives you the ID for the network card, the same ID that appears when you run
Code:
IPCONFIG /ALL
from a CMD (DOS) window.

However, given the size of the string, you're probably better off simply creating a GUID, which incorporates the MAC address, and leaving it at that.

(Also, keep in mind that MAC addresses are only theoretically unique. According to rumor, some lower end network cards have been known to reuse MAC addresses. Again, that's only a rumor.)

Hope this helps...

-- Lance
 
Hi lance
Thanks for the reply
However, this MAC ID is also a string - I need an INTEGER. Also, the MAC ID is unique to each machine - I need a unique identifier each time I run the code!!!

 
hi

What does your application do with the unique id? Are you using a database?

lou


 
Just a thought but what if you concantate (sp?) pc's ip address and date-time (down to msec)? That ought to come pretty close to being unique each time it runs both on the same pc and on different pcs running the app at same time.
 
Hi All
Thanks for your time. I don´t know what I was thinking - somehow I think of the most difficult things first. I am using a database, so why don´t I just use a unique identifier??????
Sorry all
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top