Delphi UUID generator

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 01:02:12
Mitch Wheat
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 one of the various APIs, depending on the platform. For example on Windows, it nowadays calls UuidCreate.

Nat

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.

RBA

If you're using one of the latest version of Delphi, and include SysUtils, you can call TGuid.NewGuid to generate a new guid.

NewGuid is actually implemented in a helper class for TGuid (TGuidHelper), which is declared in SysUtils.

This function calls the CreateGUID method (also in SysUtils and already mentioned in the answer by Mitch Wheat), which is actually a cross platform function that calls different libraries depending on the platform it runs on.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!