Automatically Generate a GUID

Is there any way to automatically generate a GUID programatically ?  If so how ?

I would be grateful for all advice offered.

Thanks in advance

John
johnclarkeAsked:
Who is Participating?
 
intheConnect With a Mentor Commented:
or coCreateGuid from ole32.dll :

Uses comobj;//for GuidToString function

function CoCreateGuid(out guid: TGUID): HResult; stdcall;
  external 'ole32.dll' name 'CoCreateGuid';

procedure TForm1.Button1Click(Sender: TObject);
var
  G : TGUID;
  S : string;
begin
  coCreateGuid(G);
  S := GuidToString(G);
  form1.caption := S
end;
0
 
EpsylonCommented:
Use the CreateClassID function and add ComObj to the uses clause.
0
 
vladhCommented:
listening...
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
johnclarkeAuthor Commented:
Thanks for your help!

John
0
 
EpsylonCommented:
Huh? What's wrong with CreateClassID?
0
 
jeboersemaCommented:
Hi

What is interesting here is that CoCreateGUID does not seem to work on Windows 2003 Server R2 whereas CreateClassID does.

Thought you might find this interesting.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.