title | description | keywords | ms.date | |||
---|---|---|---|---|---|---|
Including GUIDs in Driver Code |
Including GUIDs in Driver Code |
|
06/16/2017 |
To use GUIDs in a kernel-mode driver, you must do two things:
-
Include the Initguid.h header file that redefines the DEFINE_GUID macro.
The Initguid.h header file redefines the DEFINE_GUID macro to instantiate GUIDs (versus just declaring an EXTERN reference). Include this header file in the driver source file where the GUIDs should be instantiated. (User-mode applications include Objbase.h before including header files containing GUID definitions.)
-
Include the header file(s) that define the GUIDs.
After the statement to include Initguid.h, you include the header files containing the GUID definitions. A driver might include more than one header file that contains GUID definitions, including system-supplied header files and third-party header files.
The following code excerpt shows the sequence of statements for including GUIDs:
:
// include system headers here such as wdm.h
#include <initguid.h>
// include system and driver-specific header files here that contain
// GUID definitions
...
Put the above statements in one module of the driver; typically the main module. When the above statements are present, the driver refers to a GUID using its symbolic name.