Ответ:
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Слабак 07 сентября 2005 г. 19:06
В ответ на: Полу 0ff. Здесь спрошу (+) отправлено <font color=gray>АДИКМ</font> 07 сентября 2005 г. 18:05

Knowledge Base

How To Force Reenumeration of a Device Tree From an Application


PSS ID Number: 259697

Article Last Modified on 10/6/2004


--------------------------------------------------------------------------------
The information in this article applies to:


Microsoft Windows 2000 Driver Development Kit (DDK)
Microsoft Windows XP Driver Development Kit (DDK)

--------------------------------------------------------------------------------

This article was previously published under Q259697
SUMMARY
This article demonstrates how to force reenumeration of a device and all it's children by using the CM_Reenumerate_DevNode function. Reenumeration is required if you want to programmatically reenumerate devices on certain legacy buses such as Serial, which cannot detect Plug and Play devices.
MORE INFORMATION
The following code snippet shows you how to reenumerate the entire device tree. This is the programmatic equivalent of clicking the Scan For Hardware Changes menu item in the Device Manager.


BOOL ScanForHardwareChanges()
{
DEVINST devInst;
CONFIGRET status;

//
// Get the root devnode.
//

status = CM_Locate_DevNode(&devInst, NULL, CM_LOCATE_DEVNODE_NORMAL);

if (status != CR_SUCCESS) {
printf("CM_Locate_DevNode failed: %x\n", status);
return FALSE;

}

status = CM_Reenumerate_DevNode(devInst, 0);

if (status != CR_SUCCESS) {
printf("CM_Reenumerate_DevNode failed: %x\n", status));
return FALSE;
}

return TRUE;
}


The preceding function results in IRP_MN_QUERY_DEVICE_RELATIONS (BusRelations) IRP being sent to all the devices in the device tree starting at root. This operation takes a few seconds to complete.

Instead of scanning the entire tree, you can cause a specific bus device and all it's children to be reenumerated if you have a handle to it's device instance. For additional information about how to retrieve a device instance handle of a particular device by using SetupDi API calls, click the article number below to view the article in the Microsoft Knowledge Base:
259695 How To Enumerate Hardware Devices by Using SetupDi Calls


The Config Manager APIs that require Device Instance Handle can use the DevInst value of the SP_DEVINFO_DATA structure returned by the SetupDiEnumDeviceInfo/SetupDiGetDeviceInterfaceDetail function.

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru