GUID
BlitzMax Forums/BlitzMax Programming/GUID
| ||
does anybody have a function to generate a cross-platform real GUID? |
| ||
is this unique enough? |
| ||
I hope so... Not sure how a system GUID works to generate their IDs, but this seems enought for me |
| ||
I just use one Long value representing a unique computer on the network and one Long value representing an object on the local computer. Together they form the `internal` and `external` viewpoints of an object's boundary, and to generate new ones I just add 1 to the previous counter. The only drawback perhaps is you have to store the previous counter permanently like in a file rather than basing it off the date/time, and you need an orchestrated way of giving each networked machine a local id number. |
| ||
I'm not using this for networks, just to identify instances of objects at runtime, in the same computer. |
| ||
I'm not using this for networks, just to identify instances of objects at runtime, in the same computer. Couldn't you just use some sort of auto-incremented value? |
| ||
function generateGUID:int() global guid:int = 0 guid :+ 1 return guid end function you mean something like this? |
| ||
you mean something like this? that or: |
| ||
@Dreamora: He's refering to Globally Unique Identifiers (http://en.wikipedia.org/wiki/Globally_Unique_Identifier). The idea is that these are so unique and you can be sure no other software is ever going to generate the same one. |
| ||
Well that would be the hwnd, not? At least if it shouldn't hold so forever. But as he is using them locally on a single machine, I don't see why above shouldn't work. Above or a modification of it using a static table. Outside stuff most likely can not be of interest for this usage, otherwise network would be relevant (-> network devices etc) |
| ||
Why does it need to be unique if it is only within the same single computer and not over a network? All you need is an incremented integer value, there's nothing more to it. |
| ||
Becose several instances of different objects on different running applications may comunicate and identify internal data structures that have to be unique even when this data is transfered to different computers. think of it as the register signature of a OCX or the like. It has a real GUID generated by the OS. I need something that can be trusted at this level. I know there are some API on windows to generate real GUID, but I would need a BMX cross-platform implementation of this. |
| ||
Here you'll find specifications and a sample implementation in C: http://www.ics.uci.edu/~ejw/authoring/uuid-guid/draft-leach-uuids-guids-01.txt Google is your friend :) |
| ||
Thanks! That's what I was looking for! |
| ||
Microsoft has a GUID generator available for download here. |
| ||
Take a look at this |