tags:

views:

487

answers:

2

I need some code to generate UUIDs for Delphi. Any recommendations?

+14  A: 
program Guid;

{$APPTYPE CONSOLE}

uses
SysUtils;

var

Uid: TGuid;
Result: HResult;

begin
Result := CreateGuid(Uid);
if Result = S_OK then
   WriteLn(GuidToString(Uid));
end.

Under the covers CreateGuid() calls the Windows API function CoCreateGuid().

Mitch Wheat
+6  A: 

Also, if you need a GUID for an interface declaration, hit ctrl+shift+g in the code editor to insert a GUID at the caret.

Nat