Programming 版 (精华区)
发信人: zpw (zhao), 信区: Programming
标 题: obtaining plug and play hardware IDs in Windows 9
发信站: 紫 丁 香 (Wed Jul 29 20:57:47 1998), 转信
Obtaining Plug and Play Hardware IDs in Windows 95 and WDM Drivers
In a Plug and Play environment, the operating system detects the presence of
a device and notifies the driver responsible for controlling it. For Win32
Driver Model (WDM) drivers, the operating system notifies the driver by calling
the driver's AddDevice entry point. For VxDs in Windows 95 and Windows 98,
notification is in the form of a control message, namely PNP_NEWDEVNODE.
If a driver supports more than one device, and it does not handle all devices
in the same way, then it needs to determine which of the physical devices under
its control corresponds to a notification sent by the operating system. Since
the operating system assigns a unique Hardware ID to each device, one way for
the driver to identify a device is by its Hardware ID.
WDM
A WDM driver can obtain the Hardware ID of a device using the Physical Device
Object (PDO) pointer that the system passes as a parameter to AddDevice. A WDM
driver calls the system service IoGetDeviceProperty as follows:
NTSTATUS status;
ULONG ReqLen;
USHORT HardwareID[MAX_ID_SIZE];
status =IoGetDeviceProperty(
PDO,
DevicePropertyHardwareID,
sizeof(HardwareID),
HardwareID,
&ReqLen
);
IoGetDeviceProperty writes the device's hardware IDs into the provided buffer.
Compatible ID strings are delimited by commas. If the provided buffer is too
small, the service returns STATUS_BUFFER_OVERFLOW. Since the buffer may have
to be quite large, it is a good idea to allocate it temporarily from the paged
pool, and release it when no longer needed.
--
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: yaoyu.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.162毫秒