Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   C++ GUID Format wandeln (https://www.delphipraxis.net/207629-guid-format-wandeln.html)

TomyN 15. Apr 2021 21:15

GUID Format wandeln
 
Hallo,

Ich versuche gerade etwas Code von C nach Delphi zu portieren. Dabei bin ich über eine seltsame GUID Deklaration gestolpert, bei der ich irgendwie nicht weiterkomme:

Code:
GUID IID_OF_INTERFACE = { 0xA26078C5L, 0x2840, 0x4726, 0xB4, 0x27, 0xE6, 0x0F, 0xC8, 0xFE, 0xE4, 0x03 };
Ich würde das gerne in die 'String-Form' wandlen..

Tomy

Stevie 15. Apr 2021 21:29

AW: GUID Format wandeln
 
Delphi-Quellcode:
uses
  System.SysUtils;
const
  guid: TGuid = (D1: $A26078C5; D2: $2840; D3: $4726; D4: ($B4, $27, $E6, $0F, $C8, $FE, $E4, $03));
begin
  Writeln(guid.ToString);
end.

KodeZwerg 15. Apr 2021 21:45

AW: GUID Format wandeln
 
Zitat:

Zitat von Stevie (Beitrag 1487235)
Delphi-Quellcode:
uses
  System.SysUtils;
const
  guid: TGuid = (D1: $A26078C5; D2: $2840; D3: $4726; D4: ($B4, $27, $E6, $0F, $C8, $FE, $E4, $03));
begin
  Writeln(guid.ToString);
end.

Kannte ich so auch noch nicht, ist ja viel kürzer als meins hier:
Delphi-Quellcode:
program Project15;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils, System.Win.ComObj;

var
  vGUID: TGUID;
begin
  try
    vGUID.D1 := LongWord($A26078C5);
    vGUID.D2 := Word($2840);
    vGUID.D3 := Word($4726);
    vGUID.D4[0] := Byte($B4);
    vGUID.D4[1] := Byte($27);
    vGUID.D4[2] := Byte($E6);
    vGUID.D4[3] := Byte($0F);
    vGUID.D4[4] := Byte($C8);
    vGUID.D4[5] := Byte($FE);
    vGUID.D4[6] := Byte($E4);
    vGUID.D4[7] := Byte($03);
    WriteLn(GUIDToString(vGUID));
    ReadLn;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

TomyN 16. Apr 2021 07:53

AW: GUID Format wandeln
 
Hi,

Danke für's auf die Sprünge helfen.

Tomy


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz