【问题标题】:How to generate a GUID version 1 in Delphi?如何在 Delphi 中生成 GUID 版本 1?
【发布时间】:2019-08-01 05:47:53
【问题描述】:

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

unit ComObj;
function CreateClassID: string;

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

SysUtils.CreateGUID(newGUID);

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

【问题讨论】:

标签: delphi uuid guid delphi-5


【解决方案1】:

类似于 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 年前都可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-16
    • 2011-03-03
    • 1970-01-01
    • 1970-01-01
    • 2013-08-24
    • 1970-01-01
    • 2010-12-25
    • 2018-11-08
    相关资源
    最近更新 更多