DirectX SDK |
This section pertains only to application development in Visual Basic. See Direct3D Immediate Mode C/C++ Tutorials.
Before you can begin device enumeration, you need to retrieve the Direct3D object for the current display device:
Set g_d3d = g_dd.GetDirect3D()
Now, retrieve a reference to the Direct3DEnumDevices class by calling the Direct3D7.GetDevicesEnum method:
Set g_d3dEnumDevices = g_d3d.GetDevicesEnum() For i = 1 To g_d3dEnumDevices.GetCount() cmbDevice.AddItem g_d3dEnumDevices.GetName(i) Next
The preceding code sample places the user-friendly name of each enumerated device into a combo box, cmbDevice. After you have a reference to the Direct3DEnumDevices class, you can call methods that return the number of enumerated devices and information about each device:
Call the Direct3DEnumDevices.GetCount method to return the number of enumerated devices. Note that the first device is at index 1, not index 0.
Call the Direct3DEnumDevices.GetGuid method to return a text string representation of the globally-unique identifier (GUID) for an enumerated device.
Call the Direct3DEnumDevices.GetName and Direct3DEnumDevices.GetDescription methods to return text strings that contain the name and user-friendly description of the device.
Call the Direct3DEnumDevices.GetDesc method to retrieve a description of the capabilities for the device, in the form of a D3DDEVICEDESC7 type.
After you have enumerated your display driver, display modes, and devices you can select an enumerated device to be used by your application, which is the topic of Step 2: Select an Enumerated Device.