Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2877
  • Last Modified:

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
0
johnclarke
Asked:
johnclarke
1 Solution
 
EpsylonCommented:
Use the CreateClassID function and add ComObj to the uses clause.
0
 
vladhCommented:
listening...
0
 
intheCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now