const
CUSTOM_FILE_FORMAT_ID = ['{D60560E0-9FF2-11D6-BD59-00104B3458C5}'];
type
TCustomFileFormatHeader = packed record
ID: TGUID;
end;
What I don't know how to do is convert the editor generated GUID to the
16-byte binary value that TCustomFileFormatHeader.ID requires so I can
initialize the field. How do I do this? Also what _is_ the data format of
the editor generated GUID (Ctrl-Shift-G)? The format used in GUID's is
unfamilar to me: hex-numbers, separated by dashes, enclosed by curly braces,
then single quotes, then square brackets. What format does that represent,
set of bytes, etc?
thx
Ok nevermind. The answer was simple. Store only the string part of the
GUID in the 'const' item CUSTOM_FILE_FORMAT_ID and use
StringToGUID(CUSTOM_FILE_FORMAT_ID ) to prep the GUID field.
TGUID is a packed record, declared as follows:
TGUID = packed record
D1: Longword;
D2: Word;
D3: Word;
D4: array[0..7] of Byte;
end;
As you can see, the separators in the string representation of the GUID,
represent the separation between the D1-D4 fields of the TGUID. The record
itself is already a binary value. The string REPRESENTS each field of the
record in hexadecimal format.
You don't need to do the calculation yourself though, Delphi allows you to
declare a constant that uses a string literal to specify the GUID value:
const AnyGUID: TGUID = '{12345678-0A0B-0C0D-9000-000000000000}';
You can then use this constant to refer to the binary GUID in your code.
Guido
--
Guido Gybels
www.optimalcode.com/Guido
How in the world did this ever come to be?
Why not just use "array[0..15] of byte"?
> How in the world did this ever come to be?
> Why not just use "array[0..15] of byte"?
Or array[0..3] of LongWord?
And why does the string presentation not match the binary layout? It looks
like:
TGUID = packed record
D1 : LongWord;
D2 : Word;
D3 : Word;
D4 : Word;
D5 : array[0..5] of Byte;
end;
Or maybe more like D5: TribpleWord; (as if we had one <g>)
Who are those guys. anyway? <g>
--
Bill
Education guarantees neither good sense nor rational thinking.
- Posted with XanaNews -
Or how come you can't compare two GUID variables without the use of a
special function IsEqualGUID?
> John Herbster wrote:
>
> > It's that old big/little-endian problem. <g> --JohnH
>
> Yeah, well.... but still, why does the string representation have a
> different grouping than the record?
Who knows? Who invented them anyway? <g>
--
Rudy Velthuis (TeamB)
"If we knew what it was we were doing, it would not be called research,
would it?" -- Albert Einstein
> Who knows? Who invented them anyway? <g>
Well, there's plenty of info here:
http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
And some more here:
http://gsraj.tripod.com/com/basic_com/naming_guid.html
The latter reference makes it look as though the different formatting of
string and record is based on the original format specs. (But it still
seems goofy to me <g>.)
> It's that old big/little-endian problem. <g> --JohnH
Yeah, well.... but still, why does the string representation have a
different grouping than the record?
--
It's that old big/little-endian problem. <g> --JohnH