Device Management API Reference
This section details the APIs available for managing devices within the Windows operating system, covering both kernel-mode and user-mode interactions.
Core Concepts
Understanding device management in Windows involves several key concepts:
- Device Objects: Representations of physical or logical devices within the system.
- Device Drivers: Software components that allow the operating system to communicate with hardware devices.
- I/O Request Packets (IRPs): Structures used to send I/O requests from the operating system to device drivers.
- Plug and Play (PnP): The system's ability to automatically detect, configure, and manage hardware devices.
- Power Management: APIs for controlling the power states of devices.
Key APIs and Functions
User-Mode Device Management
These APIs allow applications to interact with devices and their drivers from user mode.
| Function Name | Description | Category |
|---|---|---|
CreateFile |
Opens a handle to a specified device, or creates a new one. Primarily used to interact with device drivers via their symbolic links. | Device Access |
DeviceIoControl |
Sends a control code directly to a specified device driver to perform an operation or query device information. | Device Control |
SetupDiGetClassDevs |
Retrieves a device information set that contains requested device information elements. | Device Enumeration |
SetupDiEnumDeviceInfo |
Enumerates the members of a device information set. | Device Enumeration |
SetupDiGetDeviceRegistryProperty |
Retrieves a specified device property from the device's registry key. | Device Properties |
RegisterDeviceNotification |
Registers the calling process or thread to receive PnP and system power notifications. | Notifications |
UnregisterDeviceNotification |
Unregisters a previously registered device notification. | Notifications |
Kernel-Mode Device Management
These are the lower-level APIs used by device drivers and the kernel itself.
| Function Name | Description | Category |
|---|---|---|
IoCreateDevice |
Creates a device object for a device driver. | Device Creation |
IoCreateSymbolicLink |
Creates a symbolic link object. | Device Naming |
IoDeleteDevice |
Deletes a device object. | Device Management |
IoDeleteSymbolicLink |
Deletes a symbolic link object. | Device Naming |
IoGetDeviceObjectPointer |
Retrieves a pointer to the device object for the specified device name. | Device Access |
IoQueueIoWorkItem |
Queues a work item for execution by a system thread. Used for asynchronous I/O completion. | Asynchronous I/O |
PoRegisterPowerSettingCallback |
Registers a callback routine to be called when a specified power setting changes. | Power Management |
Note: Developing kernel-mode drivers requires a deep understanding of the Windows Driver Model (WDM) or Windows Driver Foundation (WDF) and involves significant complexity and risk. Always refer to the latest WDK documentation for the most accurate and up-to-date information.