Solved

Automatically Generate a GUID

Posted on 2001-07-16
6
2,859 Views
Last Modified: 2009-07-02
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
Comment
Question by:johnclarke
6 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6286659
Use the CreateClassID function and add ComObj to the uses clause.
0
 
LVL 3

Expert Comment

by:vladh
ID: 6286976
listening...
0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6287009
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:johnclarke
ID: 6288957
Thanks for your help!

John
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6288990
Huh? What's wrong with CreateClassID?
0
 
LVL 1

Expert Comment

by:jeboersema
ID: 23773540
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question