Platform SDK: DirectX

Using GUIDs

[C++]

This topic pertains only to applications written in Visual Basic.

[Visual Basic]

Globally unique identifiers (GUIDs), which are much used in the Component Object Model (COM) that underlies DirectX, are not usually visible in DirectX for Visual Basic. However, they do occur in a few places. When they do, they are treated as strings rather than numerical values.

When you need to obtain a new GUID, run Vbguidgen.exe (in the \Samples\Multimedia\VBSamples\DXMisc\Bin folder of the SDK) and click the Copy button. Paste the GUID into your Visual Basic application and place quotation marks around it.

You can also generate GUIDs at run time by using the DirectX7.CreateNewGuid method.

An application-defined GUID could be used in a DirectPlay program as follows (where SessionData is an initialized DirectPlaySessionData object):

Const guidApp = "{AC330441-9B71-11D2-9AAB-0020781461AC}"
Call SessionData.SetGuidApplication(guidApp)

Some DirectX methods return data types that contain GUID members. These GUIDs are in the same string format as in the example.

DirectX defines many GUIDs for particular properties or other entities, and some methods require you to pass in one of these predefined GUIDs. You can do so by passing in the actual value (from a C++ header file) as a string, as in the preceding example. Usually, however, you can more conveniently pass in a documented string alias. For example, the DirectInput.CreateDevice method allows you to create a device for the standard keyboard by passing in "GUID_SysKeyboard" rather than the actual GUID.