Question

i ont ce problème, faire:

function GenGuid: String;
var
  guid: TGuid;
begin
  CreateGuid(Guid);
  Result := GuidToString(Guid);
end;

Il renvoie un guid sous forme de chaîne. Mais je fais comment pour convertir un WideString à UnicodeString? Je dois avoir le guid au format de chaîne unicode. Merci beaucoup.

UPDATE

  function myguid: string;
  var
    i: Integer;
    s: string;
    Guid: TGuid;
    t: byte;
  begin
    CreateGuid(Guid);
    s := GuidToString(Guid);
    for i := 1 to Length(s) do
    begin
      t := Ord(MidStr(s, i, 1));
      writeln (t);
    end;
    Result := ....  // for now not need, just a test
  end;

Ce faisant, t revenir 148-124 toujours et non ascii de caractère. Si je ne fais ord () puis afficher ombles correctement.

Était-ce utile?

La solution

I'm not sure if that's what you really want.

uses
  ComObj, ActiveX;

function CreateGuid: string;
var
  GUID: TGUID;
begin
  Result := '';

  if CoCreateGuid(GUID) = S_OK then
  begin
    Result := IntToHex(GUID.D1, 8) +
              IntToHex(GUID.D2, 4) +
              IntToHex(GUID.D3, 4) +
              IntToHex(GUID.D4[0], 2) +
              IntToHex(GUID.D4[1], 2) +
              IntToHex(GUID.D4[2], 2) +
              IntToHex(GUID.D4[3], 2) +
              IntToHex(GUID.D4[4], 2) +
              IntToHex(GUID.D4[5], 2) +
              IntToHex(GUID.D4[6], 2) +
              IntToHex(GUID.D4[7], 2);
  end;
end;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top