Solved

Automatically Generate a GUID

Posted on 2001-07-16
6
2,864 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

691 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