Enumerating Everything in the System

The diagnostics namespace is built on the same code base that the DxDiag tool as ships in the operating system and versions of DirectX. If you've ever run this tool, it can tell you just about everything you ever wanted to know about your system.

The diagnostics data is arranged in a hierarchal fashion. You have containers, which can contain zero-many properties, as well as zero-many children containers. Enumerating all objects is simple to do with a recursive function. In Listing A.1, look at the function that is included with the DirectX SDK DxDiagOutput sample:

Listing A.1. Outputting Diagnostic Data
 static void OutputDiagData(string parent, Container root) { try { foreach (PropertyData pd in root.Properties) ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.