Next Previous Up Top Contents Index

2.5 Making GUIDs

2.5.2 Making a GUID instance

After generating all the GUID numbers you need for the different parts of your application, the next stage is to supply those GUIDs in the proper format when you instantiate the classes, interfaces, and so on that the GUIDs will identify.

You need to supply GUIDs when making instances of classes such as <embeddable-frame> (from the DUIM-OLE-Server and DUIM-OLE-Control libraries), and<class-factory> (from the OLE-Automation and OLE-Server libraries).

The Functional Developer OLE/COM API offers two ways of doing this. The simplest, but least efficient, method is to pass the GUID as a string, in the format used in the output of the create-id utility (see "Creating GUID numbers", above). That format is:

"{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"

Where each x is a hexadecimal digit. For example:

"{C16C1BFE-41DA-11D1-9A58-006097C90313}"

You could paste these strings directly into your code, to server as init arguments for the various classes that require GUIDs.

The second, and more efficient, way to supply a GUID is to pass the output from create-id as a series of arguments to the function make-GUID, which creates the C data that the native Windows OLE/COM libraries need to represent the GUID, and returns a handle on that data as an instance of the class <REFGUID>. (The class <REFGUID> also turns up in libraries under the aliases <REFCLSID> and <REFIID>.)

The DUIM-OLE-Server, DUIM-OLE-Control, OLE-Automation, OLE-Server and OLE-Control-Framework libraries all export make-GUID.

The following is a brief description of make-GUID. See page 351 for a full reference description.

make-GUID

Function

make-GUID l w1 w2 b1 b2 b3 b4 b5 b6 b7 b8 => ID 

Returns an object representing a a globally unique identifier (GUID), created from the arguments. The ID value is an instance of the class <REFGUID>. This function creates the C structure necessary to represent a GUID in the native Windows OLE/COM libraries.
The arguments to make-GUID are taken from the output of the GUID-generation utility create-id. Given the following value from create-id:
  "{113f2c00-f87b-11cf-89fd-02070119f639}"

you need to split the value into parts as follows, and for each add the prefix #x. For example:
  define constant $my-class-ID =
    make-GUID(#x113f2c00, #xf87b, #x11cf, #x89, #xfd, #x02, #x07,
              #x01, #x19, #xf6, #x39);


OLE, COM, ActiveX and DBMS Reference - 31 MAR 2000

Next Previous Up Top Contents Index