当前位置: 首页>>代码示例>>C++>>正文


C++ SetupDiGetClassDevs函数代码示例

本文整理汇总了C++中SetupDiGetClassDevs函数的典型用法代码示例。如果您正苦于以下问题:C++ SetupDiGetClassDevs函数的具体用法?C++ SetupDiGetClassDevs怎么用?C++ SetupDiGetClassDevs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetupDiGetClassDevs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: usb_install_needs_restart_np

int usb_install_needs_restart_np(void)
{
  HDEVINFO dev_info;
  SP_DEVINFO_DATA dev_info_data;
  int dev_index = 0;
  SP_DEVINSTALL_PARAMS install_params;
  int ret = FALSE;

  dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
  dev_info = SetupDiGetClassDevs(NULL, NULL, NULL,
                                 DIGCF_ALLCLASSES | DIGCF_PRESENT);
  
  SetEnvironmentVariable("LIBUSB_NEEDS_REBOOT", "1");

  if(dev_info == INVALID_HANDLE_VALUE)
    {
      usb_error("usb_install_needs_restart_np(): getting "
                "device info set failed");
      return ret;
    }
  
  while(SetupDiEnumDeviceInfo(dev_info, dev_index, &dev_info_data))
    {
      memset(&install_params, 0, sizeof(SP_PROPCHANGE_PARAMS));
      install_params.cbSize = sizeof(SP_DEVINSTALL_PARAMS);

      if(SetupDiGetDeviceInstallParams(dev_info, &dev_info_data, 
                                       &install_params))
        {
          if(install_params.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT))
            {
              usb_message("usb_install_needs_restart_np(): restart needed");
              ret = TRUE;
            }
        }
      
      dev_index++;
    }
  
  SetupDiDestroyDeviceInfoList(dev_info);

  return ret;
}
开发者ID:Habib2014,项目名称:tinyos-2.x-contrib,代码行数:43,代码来源:install.c

示例2: AddRmForAllDevice

void AddRmForAllDevice(DWORD AffinityMask, BOOL fAdd, int targetIndex)
{
    HDEVINFO hDevInfo = INVALID_HANDLE_VALUE;
    int deviceIndex;
    SP_DEVINFO_DATA  devInfoData;
    
    devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);  //API required.
    do
    {
        hDevInfo = 
            SetupDiGetClassDevs( 
                NULL,
                NULL,
                NULL,
                DIGCF_ALLCLASSES
                | DIGCF_PRESENT
                | DIGCF_PROFILE
                );
        if (hDevInfo == INVALID_HANDLE_VALUE)
        {
            Warn("unable to get a list of devices.\n");
            break;
        }
        for ( deviceIndex = 0; 
              SetupDiEnumDeviceInfo(hDevInfo, deviceIndex,  &devInfoData);
              deviceIndex++)
        {
            if ((targetIndex < 0) || (targetIndex == deviceIndex))
            {
                if (fAdd)
                    AddFilterForDevice(hDevInfo, &devInfoData, AffinityMask);
                else
                    RmFilterForDevice(hDevInfo, &devInfoData);
            }
        }

    } while (FALSE);
    if (hDevInfo != INVALID_HANDLE_VALUE)
    {
        SetupDiDestroyDeviceInfoList(hDevInfo);
        hDevInfo = INVALID_HANDLE_VALUE;
    }
}
开发者ID:PaulJing,项目名称:Sora,代码行数:43,代码来源:IntAffinityConfig.c

示例3: vm_sys_info_get_vga_card

void vm_sys_info_get_vga_card(vm_char *vga_card)
{
    SP_DEVINFO_DATA sp_dev_info;
    HDEVINFO DeviceInfoSet;
    vm_char string1[] = VM_STRING("Display");
    Ipp32u dwIndex = 0;
    vm_char data[_MAX_LEN] = {0,};

    /* check error(s) */
    if (NULL == vga_card)
        return;

    ZeroMemory(&sp_dev_info, sizeof(SP_DEVINFO_DATA));
    ZeroMemory(&DeviceInfoSet, sizeof(HDEVINFO));

    DeviceInfoSet = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
    sp_dev_info.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
    while (SetupDiEnumDeviceInfo(DeviceInfoSet, dwIndex, &sp_dev_info))
    {
        SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
                                         &sp_dev_info,
                                         SPDRP_CLASS,
                                         NULL,
                                         (Ipp8u *) data,
                                         _MAX_LEN,
                                         NULL);
        if (!vm_string_strcmp((vm_char*)data, string1))
        {
            SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
                                             &sp_dev_info,
                                             SPDRP_DEVICEDESC,
                                             NULL,
                                             (PBYTE) vga_card,
                                             _MAX_LEN,
                                             NULL);
            break;
        }
        dwIndex++;
    }
    SetupDiDestroyDeviceInfoList(DeviceInfoSet);

} /* void vm_sys_info_get_vga_card(vm_char *vga_card) */
开发者ID:metamediatechnologies,项目名称:libvm,代码行数:42,代码来源:vm_sys_info_win32.c

示例4: enum_mobile_devices

void enum_mobile_devices(pfc::list_t<device_instance_info_t> & p_out)
{
	HDEVINFO di = SetupDiGetClassDevs(&InterfaceClassGuid, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE);

	if (di != INVALID_HANDLE_VALUE)
	{
		SP_DEVINFO_DATA did;
		memset(&did, 0, sizeof(did));
		did.cbSize = sizeof(did);

		DWORD i;
		for (i=0; SetupDiEnumDeviceInfo(di, i, &did); i++)
		{
			//if (did.ClassGuid == GUID_DEVCLASS_USB)
			{
				ULONG DevDiskLen=0;
				pfc::array_t<WCHAR> DevDisk;
				if (CR_SUCCESS == CM_Get_Device_ID_Size(&DevDiskLen, did.DevInst, NULL))
				{
					DevDisk.set_size(DevDiskLen+1);
					DevDisk.fill_null();
					if (CR_SUCCESS == CM_Get_Device_ID(did.DevInst, DevDisk.get_ptr(), DevDisk.get_size(), NULL))
					{
						if (g_check_devid_is_mobile_device(DevDisk.get_ptr()))
						{
							device_instance_info_t temp;
							temp.m_handle = did.DevInst;
							temp.m_path = DevDisk.get_ptr();
							p_out.add_item(temp);

							console::formatter() << "iPod manager: USB AMD enumerator: Found " << Tu(DevDisk.get_ptr());
						}
					}
				}
			}
		}

		SetupDiDestroyDeviceInfoList(di);
	}
	if (!p_out.get_count())
		console::formatter() << "iPod manager: USB AMD enumerator: No devices found!";
}
开发者ID:reupen,项目名称:ipod_manager,代码行数:42,代码来源:ipod_manager.cpp

示例5: rescan

static int rescan (void)
{
	int idx, idx2;

	for (idx2 = 0; guids[idx2]; idx2++) {
		HDEVINFO hDevInfo = SetupDiGetClassDevs(
			guids[idx2],
			NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
		if (hDevInfo != INVALID_HANDLE_VALUE) {
			for (idx = 0; ; idx++) {
				if (!getCDROMProperty (idx, hDevInfo, guids[idx2]))
					break;
			}
			SetupDiDestroyDeviceInfoList (hDevInfo);
		}
	}

	for (idx2 = 0; scsinames[idx2]; idx2++) {
		int max = 10;
		for (idx = 0; idx < max; idx++) {
			TCHAR tmp[100];
			HANDLE h;
			_stprintf (tmp, L"\\\\.\\%s%d", scsinames[idx2], idx);
			h = CreateFile (tmp, GENERIC_READ | GENERIC_WRITE,
				FILE_SHARE_READ | FILE_SHARE_WRITE,
				NULL, OPEN_EXISTING, 0, NULL);
			if (h != INVALID_HANDLE_VALUE) {
				adddrive (tmp, -1, -1, -1, -1, 2);
				CloseHandle (h);
				if (idx == max - 1)
					max++;
			}
		}
	}
	if (currprefs.win32_uaescsimode == UAESCSI_SPTISCAN) {
		write_log (L"SCSI adapter enumeration..\n");
		scanscsi ();
		write_log (L"SCSI adapter enumeration ends\n");
	}
	return 1;
}
开发者ID:deplinenoise,项目名称:WinUAE,代码行数:41,代码来源:blkdev_win32_spti.cpp

示例6: SetupDiGetClassDevs

QStringList QPCSC::drivers() const
{
#ifdef Q_OS_WIN
	HDEVINFO h = SetupDiGetClassDevs( 0, 0, 0, DIGCF_ALLCLASSES | DIGCF_PRESENT );
	if( !h )
		return QStringList();

	SP_DEVINFO_DATA info = { sizeof(SP_DEVINFO_DATA) };
	QStringList list;
	for( DWORD i = 0; SetupDiEnumDeviceInfo( h, i, &info ); i++ )
	{
		DWORD size = 0;
		WCHAR data[1024];

		SetupDiGetDeviceRegistryPropertyW( h, &info,
			SPDRP_CLASS, 0, LPBYTE(data), sizeof(data), &size );
		if( _wcsicmp( data, L"SmartCardReader" ) != 0 )
			continue;

		DWORD conf = 0;
		SetupDiGetDeviceRegistryPropertyW( h, &info,
			SPDRP_CONFIGFLAGS, 0, LPBYTE(&conf), sizeof(conf), &size );
		if( conf & CONFIGFLAG_DISABLED )
			continue;

		SetupDiGetDeviceRegistryPropertyW( h, &info,
			SPDRP_DEVICEDESC, 0, LPBYTE(data), sizeof(data), &size );
		QString name( (QChar*)data );

		SetupDiGetDeviceRegistryPropertyW( h, &info,
			SPDRP_HARDWAREID, 0, LPBYTE(data), sizeof(data), &size );

		list << QString( "%1 (%2)").arg( name, QString( (QChar*)data ) );
	}
	SetupDiDestroyDeviceInfoList( h );

	return list;
#else
	return readers();
#endif
}
开发者ID:open-eid,项目名称:qt-common,代码行数:41,代码来源:QPCSC.cpp

示例7: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	WCHAR *wDeviceName = L"TAP-Win32 Adapter V9";
	SP_DEVINFO_DATA deviceInfoData;
	HDEVINFO hDevHandle;

	deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
	hDevHandle = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT);

	wcscpy_s(wDeviceInstanceId, MAX_PATH, L"NULL");

	FillDeviceInstanceId(hDevHandle, deviceInfoData, wDeviceName);

	SetupDiDestroyDeviceInfoList(hDevHandle); 

	if (wcscmp(wDeviceInstanceId, L"NULL") == 0)
	{
		wprintf(L"An error occurred.\n");

		return 1;
	} 

	WCHAR wBind[1024];

	RtlZeroMemory(wBind, 1024);

	// Prepend 'ms_tcpip->' to the device instance ID
	wcscpy_s(wBind, L"ms_tcpip->");
	wcscat_s(wBind, wDeviceInstanceId);

	RtlZeroMemory(wDeviceInstanceId, MAX_PATH);

	wcscpy_s(wDeviceInstanceId, MAX_PATH, wBind);

	wprintf(L"Changing binding order for %s...\n", wDeviceInstanceId);

	ChangeNicBindingOrder();

	return 0;
}
开发者ID:beaugunderson,项目名称:ChangeBindingOrder,代码行数:40,代码来源:ChangeBindingOrder.cpp

示例8: test_SetupDiGetClassDevsA

static void test_SetupDiGetClassDevsA(void)
{
    HDEVINFO device_info;

    SetLastError( 0xdeadbeef );
    device_info = SetupDiGetClassDevs( NULL, NULL, NULL, 0 );
    ok( device_info == INVALID_HANDLE_VALUE,
        "Fail expected\n" );
    ok_lasterr( ERROR_INVALID_PARAMETER );

    SetLastError( 0xdeadbeef );
    device_info = SetupDiGetClassDevs( NULL, NULL, NULL, DIGCF_ALLCLASSES );
    ok( device_info != INVALID_HANDLE_VALUE,
        "Error reported %lx\n", GetLastError() );
    SetLastError( 0xdeadbeef );
    ok( SetupDiDestroyDeviceInfoList( device_info ),
        "Error reported %lx\n", GetLastError() );

    SetLastError( 0xdeadbeef );
    device_info = SetupDiGetClassDevs( NULL, NULL, NULL, DIGCF_DEVICEINTERFACE );
    ok( device_info == INVALID_HANDLE_VALUE,
        "Fail expected\n" );
    ok_lasterr( ERROR_INVALID_PARAMETER );

    SetLastError( 0xdeadbeef );
    device_info = SetupDiGetClassDevs( &test_class_guid, NULL, NULL, 0 );
    ok( device_info != INVALID_HANDLE_VALUE,
        "Error reported %lx\n", GetLastError() );
    SetLastError( 0xdeadbeef );
    ok( SetupDiDestroyDeviceInfoList( device_info ),
        "Error reported %lx\n", GetLastError() );

    SetLastError( 0xdeadbeef );
    device_info = SetupDiGetClassDevs( NULL, "(invalid enumerator)", NULL, DIGCF_ALLCLASSES );
    ok( device_info == INVALID_HANDLE_VALUE,
        "Fail expected\n" );
    ok_lasterr( ERROR_INVALID_DATA );

    SetLastError( 0xdeadbeef );
    device_info = SetupDiGetClassDevs( NULL, "Root", NULL, DIGCF_ALLCLASSES );
    ok( device_info != INVALID_HANDLE_VALUE,
        "Error reported %lx\n", GetLastError() );
    SetLastError( 0xdeadbeef );
    ok( SetupDiDestroyDeviceInfoList( device_info ),
        "Error reported %lx\n", GetLastError() );
}
开发者ID:GYGit,项目名称:reactos,代码行数:46,代码来源:devclass.c

示例9: SetupDiGetClassDevs

// ////////////////////////////////////////////////////////////////////////////////
// ÉèÖÃÍø¿¨×´Ì¬
// 1 - ÆôÓÃ
// 0 - ½ûÓÃ
//
BOOL NetTools::SetMacState(BOOL bState)
{
	HDEVINFO hDevInfo = SetupDiGetClassDevs(
		NULL,
		NULL,
		0,
		DIGCF_PRESENT | DIGCF_ALLCLASSES
		);

	if ( INVALID_HANDLE_VALUE == hDevInfo )
	{
		DebugTools::OutputDebugPrintf(L"[NetTools] [SetMacState] SetupDiGetClassDevs Failed.\r\n");
		return FALSE;
	}

	SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};

	for (int i = 0; SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); i++)
	{

		if ( NetToolsInternal::IsClassNet(&DeviceInfoData.ClassGuid) )
		{
			DWORD dwStatus = bState ? DICS_ENABLE : DICS_DISABLE;

			if ( !NetToolsInternal::StateChange(dwStatus, i, hDevInfo) )
			{
				DebugTools::OutputDebugPrintf(L"[NetTools] [SetMacState] StateChange Failed.\r\n");
			}
			else
			{
				return TRUE;
			}
		}
	}

	return TRUE;
}
开发者ID:sssooonnnggg,项目名称:LibSrn,代码行数:42,代码来源:NetTools.cpp

示例10: SetupDiGetClassDevs

//------------------------------------------------------------------------
// GetNumDevices()
//
// Counts the number of Silabs USB devices listed in the registry.
//------------------------------------------------------------------------
DWORD CUsbIF::GetNumDevices()
{
	DWORD numDevices = 0;

	// Retrieve device list for GUID that has been specified.
	HDEVINFO hDevInfoList = SetupDiGetClassDevs (&m_GUID, NULL, NULL, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE)); 

	if (hDevInfoList != NULL)
	{
		SP_DEVICE_INTERFACE_DATA deviceInfoData;

		for (int index = 0; index < 127;index++)
		{
			// Clear data structure
			ZeroMemory(&deviceInfoData, sizeof(deviceInfoData));
			deviceInfoData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);

			// retrieves a context structure for a device interface of a device information set.
			if (SetupDiEnumDeviceInterfaces (hDevInfoList, 0, &m_GUID, index, &deviceInfoData)) 
			{
				numDevices++;
			}
			else
			{
				if ( GetLastError() == ERROR_NO_MORE_ITEMS ) 
					break;
			}
		}
	}

	// SetupDiDestroyDeviceInfoList() destroys a device information set
	// and frees all associated memory.
	SetupDiDestroyDeviceInfoList (hDevInfoList);

	return numDevices;
}
开发者ID:weidaye,项目名称:hw-example,代码行数:41,代码来源:UsbIF.cpp

示例11: OpenDeviceList

DWORD
OpenDeviceList(
    IN LPGUID InterfaceGuid,
    OUT HDEVINFO * OutHandle)
{
    HDEVINFO DeviceHandle;

    DeviceHandle = SetupDiGetClassDevs(InterfaceGuid,
                                       NULL,
                                       NULL,
                                       DIGCF_DEVICEINTERFACE); //DIGCF_PRESENT

    /* check for success */
    if (DeviceHandle == INVALID_HANDLE_VALUE)
    {
        /* failed to create device list */
        return GetLastError();
    }

    /* store result */
    *OutHandle = DeviceHandle;

    return ERROR_SUCCESS;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:24,代码来源:devicelist.c

示例12: xsEnumerateSerialPorts

/*! \brief Enumerate Xsens USB devices

	If the OS already has drivers running for a device, the device should already have been
	found by xsEnumerateSerialPorts().

	\param[in,out] ports The list of serial ports to append to
*/
bool xsEnumerateUsbDevices(XsPortInfoList& ports)
{
	XsPortInfo current;
#ifdef USE_WINUSB
	BOOL bResult = FALSE;
	ULONG length;
	ULONG requiredLength=0;

	// {FD51225C-700A-47e5-9999-B2D9031B88ED}
	GUID guid = { 0xfd51225c, 0x700a, 0x47e5, { 0x99, 0x99, 0xb2, 0xd9, 0x3, 0x1b, 0x88, 0xed } };

	HDEVINFO deviceInfo;
	SP_DEVICE_INTERFACE_DATA interfaceData;
	PSP_DEVICE_INTERFACE_DETAIL_DATA_A detailData = NULL;

	deviceInfo = SetupDiGetClassDevs(&guid, NULL, NULL,	DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);

	// Initialize variables.
	interfaceData.cbSize = sizeof(SP_INTERFACE_DEVICE_DATA);
	int port = 0;
	for (DWORD dwIndex = 0; port == 0; ++dwIndex)
	{
		BOOL bRet = SetupDiEnumDeviceInterfaces( deviceInfo, NULL, &guid, dwIndex, &interfaceData);
		if (!bRet)
		{
			if (GetLastError() == ERROR_NO_MORE_ITEMS)
				break;
		}
		else
		{
			if (!SetupDiGetDeviceInterfaceDetail(deviceInfo, &interfaceData, NULL, 0, &requiredLength, NULL))
			{
				if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
				{
					SetupDiDestroyDeviceInfoList(deviceInfo);
					return false;
				}
			}
			detailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A)LocalAlloc(LMEM_FIXED, requiredLength);
			if (NULL == detailData)
			{
				SetupDiDestroyDeviceInfoList(deviceInfo);
				return false;
			}

			detailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
			length = requiredLength;
			SP_DEVINFO_DATA DevInfoData;
			DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
			bResult = SetupDiGetDeviceInterfaceDetailA(deviceInfo, &interfaceData, detailData, length, &requiredLength, &DevInfoData);

			if (!bResult)
			{
				LocalFree(detailData);
				SetupDiDestroyDeviceInfoList(deviceInfo);
				return false;
			}

			unsigned char serialNumber[256];
			char* ptrEnd, *ptrStart = strchr(detailData->DevicePath, '#');
			if (!ptrStart)
				continue;
			ptrStart = strchr(ptrStart+1, '#');
			if (!ptrStart)
				continue;
			ptrEnd = strchr(ptrStart+1, '#');
			if (!ptrEnd)
				continue;

			strncpy((char*)serialNumber, ptrStart+1, ptrEnd-ptrStart-1);
			serialNumber[ptrEnd-ptrStart-1] = '\0';

			current.setPortName(detailData->DevicePath);

			int id = 0;
			sscanf((const char *)serialNumber, "%X", &id);
			current.setDeviceId((uint32_t) id);

			ports.push_back(current);
		}
	}

	SetupDiDestroyDeviceInfoList(deviceInfo);
	return true;
#elif defined(HAVE_LIBUSB)
	XsLibUsb libUsb;
	libusb_context *context;
	int result = libUsb.init(&context);
	if (result != LIBUSB_SUCCESS)
		return true;

	libusb_device **deviceList;
	ssize_t deviceCount = libUsb.get_device_list(context, &deviceList);
//.........这里部分代码省略.........
开发者ID:loomplyty,项目名称:IMU,代码行数:101,代码来源:enumerateusbdevices.cpp

示例13: usbOpenDevice

int usbOpenDevice(usbDevice_t **device, int vendor, char *vendorName, int product, char *productName, int usesReportIDs)
{
GUID                                hidGuid;        /* GUID for HID driver */
HDEVINFO                            deviceInfoList;
SP_DEVICE_INTERFACE_DATA            deviceInfo;
SP_DEVICE_INTERFACE_DETAIL_DATA     *deviceDetails = NULL;
DWORD                               size;
int                                 i, openFlag = 0;  /* may be FILE_FLAG_OVERLAPPED */
int                                 errorCode = USB_ERROR_NOTFOUND;
HANDLE                              handle = INVALID_HANDLE_VALUE;
HIDD_ATTRIBUTES                     deviceAttributes;
				
    HidD_GetHidGuid(&hidGuid);
    deviceInfoList = SetupDiGetClassDevs(&hidGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
    deviceInfo.cbSize = sizeof(deviceInfo);
    for(i=0;;i++){
        if(handle != INVALID_HANDLE_VALUE){
            CloseHandle(handle);
            handle = INVALID_HANDLE_VALUE;
        }
        if(!SetupDiEnumDeviceInterfaces(deviceInfoList, 0, &hidGuid, i, &deviceInfo))
            break;  /* no more entries */
        /* first do a dummy call just to determine the actual size required */
        SetupDiGetDeviceInterfaceDetail(deviceInfoList, &deviceInfo, NULL, 0, &size, NULL);
        if(deviceDetails != NULL)
            free(deviceDetails);
        deviceDetails = malloc(size);
        deviceDetails->cbSize = sizeof(*deviceDetails);
        /* this call is for real: */
        SetupDiGetDeviceInterfaceDetail(deviceInfoList, &deviceInfo, deviceDetails, size, &size, NULL);
        DEBUG_PRINT(("checking HID path \"%s\"\n", deviceDetails->DevicePath));
        /* attempt opening for R/W -- we don't care about devices which can't be accessed */
        handle = CreateFile(deviceDetails->DevicePath, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, openFlag, NULL);
        if(handle == INVALID_HANDLE_VALUE){
            DEBUG_PRINT(("opening failed: %d\n", (int)GetLastError()));
            /* errorCode = USB_ERROR_ACCESS; opening will always fail for mouse -- ignore */
            continue;
        }
        deviceAttributes.Size = sizeof(deviceAttributes);
        HidD_GetAttributes(handle, &deviceAttributes);
        DEBUG_PRINT(("device attributes: vid=%d pid=%d\n", deviceAttributes.VendorID, deviceAttributes.ProductID));
        if(deviceAttributes.VendorID != vendor || deviceAttributes.ProductID != product)
            continue;   /* ignore this device */
        errorCode = USB_ERROR_NOTFOUND;
        if(vendorName != NULL && productName != NULL){
            char    buffer[512];
            if(!HidD_GetManufacturerString(handle, buffer, sizeof(buffer))){
                DEBUG_PRINT(("error obtaining vendor name\n"));
                errorCode = USB_ERROR_IO;
                continue;
            }
            convertUniToAscii(buffer);
            DEBUG_PRINT(("vendorName = \"%s\"\n", buffer));
            if(strcmp(vendorName, buffer) != 0)
                continue;
            if(!HidD_GetProductString(handle, buffer, sizeof(buffer))){
                DEBUG_PRINT(("error obtaining product name\n"));
                errorCode = USB_ERROR_IO;
                continue;
            }
            convertUniToAscii(buffer);
            DEBUG_PRINT(("productName = \"%s\"\n", buffer));
            if(strcmp(productName, buffer) != 0)
                continue;
        }
        break;  /* we have found the device we are looking for! */
    }
    SetupDiDestroyDeviceInfoList(deviceInfoList);
    if(deviceDetails != NULL)
        free(deviceDetails);
    if(handle != INVALID_HANDLE_VALUE){
        *device = (usbDevice_t *)handle;
        errorCode = 0;
    }
    return errorCode;
}
开发者ID:CristianDragu,项目名称:Projects,代码行数:76,代码来源:usb-windows.c

示例14: strcpy

int iKX::init(int device,int ignore_winmm)
{
    int i=0;
    char string[1024];
    int ret=-1;

    if(device_num!=-1) // double init
    {
     strcpy(error_name,"interface already initialized");
     debug("iKX init(): already initialized\n");
     return -7;
    }

    strcpy(error_name,"no error");

    // asio init
    asio_inited=0;
    last_asio_voice=-1;

    asio_method=0;

     asio_iks_property=NULL;
     asio_secondary_buffer=NULL;
     asio_prim_buffer=NULL;
     asio_ds=NULL;

     pRenderEnumerator=0;
     pRenderFilter=0;
     pRenderPin=0;

    memset(asio_mem_table,0,sizeof(asio_mem_table));

    memset(&guid_,0,sizeof(guid_));

    device_num=device;
    
    HDEVINFO hInfo=SetupDiGetClassDevs((GUID *)&KSCATEGORY_AUDIO,NULL,NULL,DIGCF_DEVICEINTERFACE |DIGCF_PRESENT);
    
    if(hInfo==INVALID_HANDLE_VALUE)
    { 
     debug("iKX init(): setupdigetclassdevs failed [%x]\n",GetLastError());
     strcpy(error_name,"error enumerating devices");
     return ret; 
    }
    
    SP_DEVINFO_DATA devinfo;
    devinfo.cbSize=sizeof(devinfo);

    while(SetupDiEnumDeviceInfo(hInfo,i,&devinfo))
    {
        i++;
        if(SetupDiGetDeviceInstanceId(hInfo,&devinfo,string,sizeof(string),NULL))
        {
            if(
               (strstr(string,"VEN_1102&DEV_0002")==NULL) &&
               (strstr(string,"VEN_1102&DEV_0004")==NULL) &&
               (strstr(string,"VEN_1102&DEV_0008")==NULL) 
              ) // FIXME: bad test, actually :(
            { 
              continue; 
            }
        }
        else
        {
         continue;
         }

        SP_DEVICE_INTERFACE_DATA data;
        data.cbSize=sizeof(data);
        int j=0;
        while(SetupDiEnumDeviceInterfaces(hInfo,&devinfo,(GUID *)&KSCATEGORY_AUDIO,j++,&data)==TRUE)
        {
            DWORD ReqLen=0;
            SetupDiGetInterfaceDeviceDetail (
                hInfo,
                &data,
                NULL,
                0,
                &ReqLen,
            NULL
            );

                PSP_INTERFACE_DEVICE_DETAIL_DATA m_Detail = PSP_INTERFACE_DEVICE_DETAIL_DATA(new char[ReqLen]);

                if ( m_Detail )
                {
                        m_Detail->cbSize = sizeof SP_INTERFACE_DEVICE_DETAIL_DATA;

                        if(SetupDiGetInterfaceDeviceDetail (
                            hInfo,
                            &data,
                            m_Detail,
                            ReqLen,
                            &ReqLen,
                            NULL
                            )==TRUE)
                        {
                            if(strstr(m_Detail->DevicePath,"kx_topo1")!=NULL)
                            {
                             HKEY key=SetupDiOpenDeviceInterfaceRegKey(hInfo,&data,0,KEY_ALL_ACCESS);
//.........这里部分代码省略.........
开发者ID:kxproject,项目名称:kx-audio-driver,代码行数:101,代码来源:interface-win.cpp

示例15: SetIcon

// CDeviceSelect message handlers
BOOL CDeviceSelect::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    HDEVINFO                            hardwareDeviceInfo;
    PSP_DEVICE_INTERFACE_DETAIL_DATA    deviceInterfaceDetailData = NULL;
    ULONG                               predictedLength = 0;
    ULONG                               requiredLength = 0, bytes=0;
	WCHAR								szBda[13] = {0};
	HANDLE								hDevice = INVALID_HANDLE_VALUE;

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

    m_numDevices = 0;

    if ((hardwareDeviceInfo = SetupDiGetClassDevs (NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT)) != INVALID_HANDLE_VALUE)
    {
        SP_DEVINFO_DATA DeviceInfoData;

        memset(&DeviceInfoData, 0, sizeof(DeviceInfoData));
        DeviceInfoData.cbSize = sizeof(DeviceInfoData);

        WCHAR szService[80];
        GUID guid;
        if (m_bWin8)
            guid = GUID_LONG_CHAR_SERVICE;
        else
        {
            guid.Data1 = (GUID_LONG_CHAR_SERVICE.Data4[4]     ) + (GUID_LONG_CHAR_SERVICE.Data4[5] << 8) + (GUID_LONG_CHAR_SERVICE.Data4[6] << 16) + (GUID_LONG_CHAR_SERVICE.Data4[7] << 24);
            guid.Data2 = (GUID_LONG_CHAR_SERVICE.Data4[2]     ) + (GUID_LONG_CHAR_SERVICE.Data4[3] << 8);
            guid.Data3 = (GUID_LONG_CHAR_SERVICE.Data4[0]     ) + (GUID_LONG_CHAR_SERVICE.Data4[1] << 8);
            guid.Data4[0] = (GUID_LONG_CHAR_SERVICE.Data3      ) & 0xff;
            guid.Data4[1] = (GUID_LONG_CHAR_SERVICE.Data3 >> 8 ) & 0xff;
            guid.Data4[2] = (GUID_LONG_CHAR_SERVICE.Data2      ) & 0xff;
            guid.Data4[3] = (GUID_LONG_CHAR_SERVICE.Data2 >> 8 ) & 0xff;
            guid.Data4[4] = (GUID_LONG_CHAR_SERVICE.Data1      ) & 0xff;
            guid.Data4[5] = (GUID_LONG_CHAR_SERVICE.Data1 >> 8 ) & 0xff;
            guid.Data4[6] = (GUID_LONG_CHAR_SERVICE.Data1 >> 16) & 0xff;
            guid.Data4[7] = (GUID_LONG_CHAR_SERVICE.Data1 >> 24) & 0xff;
        }
        UuidToString(szService, 80, &guid);
        ods ("%S\n", szService);
        for (DWORD n = 0; SetupDiEnumDeviceInfo(hardwareDeviceInfo, n, &DeviceInfoData); n++)
        {
            DWORD dwBytes = 0;

            SetupDiGetDeviceInstanceId(hardwareDeviceInfo, &DeviceInfoData, NULL, 0, &dwBytes);

            PWSTR szInstanceId = new WCHAR [dwBytes];
            if (szInstanceId)
            {
                if (SetupDiGetDeviceInstanceId(hardwareDeviceInfo, &DeviceInfoData, szInstanceId, dwBytes, &dwBytes))
                {
                    _wcsupr_s (szInstanceId, dwBytes);
//                    if (wcsstr(szInstanceId, L"BTHENUM"))
//                    {
//                        OutputDebugStringW(szInstanceId);
//                        OutputDebugStringW(L"\n");
                    if (wcsstr(szInstanceId, szService))
                    {
                        OutputDebugStringW(szInstanceId);
                        WCHAR buf[13];
                        wchar_t* pStart;
                        wchar_t* pEnd;
                        if (m_bWin8)
                        {
                            pStart = wcsrchr(szInstanceId, '_');
                            pEnd = wcsrchr(szInstanceId, '\\');
                        }
                        else
                        {
                            pStart = wcsrchr(szInstanceId, '&');
                            pEnd = wcsrchr(szInstanceId, '_');
                        }
                        if (pStart && pEnd)
                        {
                            *pEnd = 0;
                            wcscpy_s(buf, pStart + 1);
                            m_lbDevices.AddString(buf);
                            m_numDevices++;
                        }
//                    }
                    }
                }
                delete[] szInstanceId;
            }
        }
        SetupDiDestroyDeviceInfoList(hardwareDeviceInfo);
    }
开发者ID:robbie-cao,项目名称:Grush_Gen1_Firmware_Broadcom,代码行数:93,代码来源:DeviceSelect.cpp


注:本文中的SetupDiGetClassDevs函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。