Listing Loaded Devices in Windows CE

The APIs FindFirstDevice and FindNextDevice can be used to search for a device currently loaded in Windows CE 5.0 or above. These APIs are not available in versions prior to Windows CE 5.0. The following are the syntax:

HANDLE FindFirstDevice(DeviceSearchType searchType,LPCVOID pvSearchParam,
PDEVMGR_DEVICE_INFORMATION pdi);

BOOL FindNextDevice(HANDLE h,, DEVMGR_DEVICE_INFORMATION pdi);

If successful the FindFirstDevice returns a device handle which can be used for subsequent FineNextDevice.The FindNextDevice returns TRUE if there are more devices to nd otherwise returns FALSE

#include <windows.h>
#include "bldver.h"
void EnumerateRunningDrivers( void )
{
    #if CE_MAJOR_VER>4
        HANDLE hDriver;
        DeviceSearchType DeviceSearch = DeviceSearchByLegacyName;
        DEVMGR_DEVICE_INFORMATION DeviceInfo;
        DeviceInfo.dwSize = sizeof( DEVMGR_DEVICE_INFORMATION );
        hDriver = FindFirstDevice(DeviceSearch, L"*", &DeviceInfo);
        if( hDriver != INVALID_HANDLE_VALUE )
       {
            RETAILMSG( 1, (TEXT("Legacy Key Name BUS\n")));
            do
           {
               RETAILMSG( 1, (TEXT("%s %s %s %s\n"),
                                        DeviceInfo.szLegacyName,
                                        DeviceInfo.szDeviceKey,
                                        DeviceInfo.szDeviceName,
                                        DeviceInfo.szBusName ));
            } while( FindNextDevice( hDriver, &DeviceInfo ) );
            FindClose( hDriver );
        }
   #else
    RETAILMSG( 1, (TEXT("Cannot find drivers Windows CE Version doesn't support                    
                             function\n")));
    #endif
}


Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

PR, PN and PV Variable in Yocto