gpt4 book ai didi

delphi - 如何在 Delphi 中生成 GUID 版本 1?

转载 作者:行者123 更新时间:2023-12-03 15:22:56 25 4
gpt4 key购买 nike

有没有办法在 Delphi 5 中生成 GUID v1(基于时间)?我发现了这个功能...

unit ComObj;
function CreateClassID: string;

但我不确定它是否生成基于时间的 GUID。我也知道这个...

SysUtils.CreateGUID(newGUID);

...它调用生成 GUID 版本 4(随机)的 Windows API CoCreateGUID

最佳答案

与 CreateGUID 的实现方式类似 - 使用 UuidCreateSequential:

uses
Windows;

function UuidCreateSequential(out guid: TGUID): Longint; stdcall; external 'rpcrt4.dll' name 'UuidCreateSequential';

function CreateGUID_V1(out Guid: TGUID): HResult;
begin
Result := HResultFromWin32(UuidCreateSequential(Guid));
end;

我这里没有 Delphi 5,所以不确定这里使用的所有东西是否在 20 年前就可用。

关于delphi - 如何在 Delphi 中生成 GUID 版本 1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57302519/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com