DirectX SDK |
This topic pertains only to applications written in C++. For an introduction to programming for DirectX in Visual Basic, see Visual Basic Programming Topics.
DirectX contains many methods that are used to enumerate hardware resources or other items available to the application. These methods all work in fundamentally the same way.
Prototype callback functions are documented for each DirectX component. The application declares its own functions with the same return values and parameters as these prototypes. Callback functions are declared as type CALLBACK, WINAPI, or FAR PASCAL, which are all equivalent.
When the application calls an enumeration method, it supplies a pointer to the appropriate callback function that it has implemented. The method calls the function once for each item that qualifies for enumeration and passes in information about the item. Within the function, the application can use this information to perform any sort of task, such as building a list or looking for particular device capabilities. The enumeration method returns when all items have been enumerated or when the callback function returns a value indicating that enumeration can stop (either FALSE or a particular HRESULT, depending on the return type of the callback).
For an example, see DirectInput Device Enumeration.