How to generate an unique computer id on Delphi?

后端 未结 4 1280
清酒与你
清酒与你 2020-12-09 13:42

How can I quickly generate an unique computer id for a delphi app? I used to do it easly with c#, but this failed sometimes. I do want the ID to be \"static\" but I don\'t c

4条回答
  •  失恋的感觉
    2020-12-09 14:15

    I'm not exactly sure what you're asking? It might help if you clarified why you need the "unique computer id".

    Option 1

    The bit:

    "I was planning to store it in the registry and check it when the app starts, and if it changed update the registry."

    gives me the impression you're trying to detect a different (newer) version of the app and/or identify different apps within a suite.

    If this is the case, then simply pressing Ctrl+Shift+G will generate a unique GUID for you and insert it at your current cursor position in code. You may want to also look at the version information; perhaps auto-increment build numbers?

    Option 2

    If you're trying to in some way identify unique installations on different computers, take a look at the CreateGUID function in plainth's answer.

    Option 3

    You mentioned that you "don't care if the id changes because of a hardware change or OS reinstallation". I'm not sure if this is an important fact like: you're trying to detect hardware changes? After all, you did say you don't care; but then why mention this at all?

    Option 4

    Something else I haven't considered?

提交回复
热议问题