Capture Device Selection (Windows CE 5.0)

Windows CE 5.0
Send Feedback

Applies to: Devices based on Windows Mobile Version 5.0 and later

A Windows CE-based device can supports more than one capture (camera) device. You can enumerate all the capture devices through calls to FindFirstDevice and FindNextDevice. In your call to FindFirstDevice, set the searchType set to DeviceSearchByGuid and pvSearchParam set to DEVCLASS_CAMERA_GUID, which is the GUID value {0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A, 0x93, 0x3E, 0x4D, 0x7E, 0x3C, 0x86}. It is possible to use other search types, but using the device class GUID is the most reliable way to find a capture device. Once you have obtained a search handle from FindFirstDevice, you can make successive calls to FindNextDevice to locate all of the available capture devices. The following code shows how to

GetFirstCameraDriver( WCHAR *pwzName ) {
  HRESULT hr = S_OK;
  HANDLE handle = NULL;
  GUID guidCamera = { 0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A,
                      0x93, 0x3E, 0x4D, 0x7E, 0x3C, 0x86 };

  if( pwzName == NULL ) {
    return E_POINTER;

  di.dwSize = sizeof(di);

  handle = FindFirstDevice( DeviceSearchByGuid, &guidCamera, &di );
  if(( handle == NULL ) || ( di.hDevice == NULL )) {
    ERR( HRESULT_FROM_WIN32( GetLastError() ));

  StringCchCopy( pwzName, MAX_PATH, di.szLegacyName );
  FindClose( handle );
  return hr;

After choosing one of the available capture devices, you must attach it to a filter graph to read data from it. You do this by finding the capture device's name and then attaching that name to the filter graph through a property bag when you initialize the filter. A capture device's name is stored in the szLegacyName member of the DEVMGR_DEVICE_INFORMATION structure returned by FindFirstDevice or FindNextDevice. When the filter captures data it uses the capture device name stored in the property bag to identify the source of the data.

The following code shows how to pass the name of the capture device, varCamName, to a filter through an object, PropBag, that implements an IPropertyBag interface.

// Initialize the video capture filter
pVideoCap.CoCreateInstance( CLSID_VideoCapture ); 
pVideoCap.QueryInterface( &pPropertyBag );
varCamName = L"CAM1:";
if(( varCamName.vt == VT_BSTR ) == NULL ) {
PropBag.Write( L"VCapName", &varCamName );   
pPropertyBag->Load( &PropBag, NULL );
pGraph->AddFilter( pVideoCap, L"Video capture source" );

The string L"VCapName" identifies the filter property for the name of the video capture device.

See Also

Video Capture

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.