怎么样检测主板是否支持usb2.0? 用程序说明,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // 原理:USB2.0的主机控制器类型是EHCI,PCI设备ID是PCI\CC_0C0320,因此只要找到这个设备ID就可以认为主板支持USB2.0#include <windows.h>#include <setupapi.h>#include <stdio.h>#pragma comment(lib, "setupapi.lib")int main(int argc, char* argv[]){ HDEVINFO DeviceInfoSet; SP_DEVINFO_DATA DeviceInfoData; DWORD i,err; BOOL bFind = FALSE;// char* CompatibleID = argv[1]; char* CompatibleID = "PCI\\CC_0C0320"; DeviceInfoSet = SetupDiGetClassDevs(NULL, // All Classes 0, 0, DIGCF_ALLCLASSES | DIGCF_PRESENT ); // All devices present on system if (DeviceInfoSet == INVALID_HANDLE_VALUE) { printf("GetClassDevs(All Present Devices fail"); return 1; } DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); for (i=0;SetupDiEnumDeviceInfo(DeviceInfoSet,i,&DeviceInfoData);i++) { DWORD DataT; LPTSTR p,buffer = NULL; DWORD buffersize = 0; while (!SetupDiGetDeviceRegistryProperty( DeviceInfoSet, &DeviceInfoData, SPDRP_COMPATIBLEIDS, &DataT, (PBYTE)buffer, buffersize, &buffersize)) { if (GetLastError() == ERROR_INVALID_DATA) { break; } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { if (buffer) LocalFree(buffer); buffersize *= 2; buffer = LocalAlloc(LPTR,buffersize); } else { printf("GetDeviceRegistryProperty fail"); goto cleanup_DeviceInfo; } } if (GetLastError() == ERROR_INVALID_DATA) continue; for (p=buffer;*p&&(p<&buffer[buffersize]);p+=lstrlen(p)+sizeof(TCHAR)) {// printf(TEXT("Compare device ID: [%s]\n"),p); if (!stricmp(CompatibleID,p)) { printf(TEXT("Found! [%s]\n"),p); bFind = TRUE; break; } } if (buffer) LocalFree(buffer); if (bFind) { break; } } if ((GetLastError()!=NO_ERROR)&&(GetLastError()!=ERROR_NO_MORE_ITEMS)) { printf("EnumDeviceInfo fail"); } // // Cleanup. // cleanup_DeviceInfo: err = GetLastError(); SetupDiDeleteDeviceInfo(DeviceInfoSet, &DeviceInfoData); return err;} 大恒CG400采集卡采集图像实时显示到对话框的问题 是通过tcp直接传输还是通过数据库传输比较好呢? bcg的CBCGPDockingControlBar获取关闭消息问题 请问一个安装程序是如何写的? 关于dll的一些问题。 各位,在VC中如何用程序控制鼠标自动移动 (500分求助!)***关于COM+EVENT*** 谁能帮我????OpenGL.... 谁有能一下子读入JPG文件,在内存中建立位图句柄供图象处理用的函数? help me!!!!!!!? uninstall win2000 sp3 and install win2000 sp2 初学指针,乱七八糟,散分100求教明师指点
#include <setupapi.h>
#include <stdio.h>#pragma comment(lib, "setupapi.lib")int main(int argc, char* argv[])
{
HDEVINFO DeviceInfoSet;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i,err; BOOL bFind = FALSE;// char* CompatibleID = argv[1];
char* CompatibleID = "PCI\\CC_0C0320"; DeviceInfoSet = SetupDiGetClassDevs(NULL, // All Classes
0,
0,
DIGCF_ALLCLASSES | DIGCF_PRESENT ); // All devices present on system if (DeviceInfoSet == INVALID_HANDLE_VALUE) {
printf("GetClassDevs(All Present Devices fail");
return 1;
} DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); for (i=0;SetupDiEnumDeviceInfo(DeviceInfoSet,i,&DeviceInfoData);i++) {
DWORD DataT;
LPTSTR p,buffer = NULL;
DWORD buffersize = 0;
while (!SetupDiGetDeviceRegistryProperty(
DeviceInfoSet,
&DeviceInfoData,
SPDRP_COMPATIBLEIDS,
&DataT,
(PBYTE)buffer,
buffersize,
&buffersize))
{
if (GetLastError() == ERROR_INVALID_DATA) {
break;
}
else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
if (buffer)
LocalFree(buffer); buffersize *= 2;
buffer = LocalAlloc(LPTR,buffersize);
}
else {
printf("GetDeviceRegistryProperty fail");
goto cleanup_DeviceInfo;
}
} if (GetLastError() == ERROR_INVALID_DATA)
continue;
for (p=buffer;*p&&(p<&buffer[buffersize]);p+=lstrlen(p)+sizeof(TCHAR))
{
// printf(TEXT("Compare device ID: [%s]\n"),p); if (!stricmp(CompatibleID,p))
{
printf(TEXT("Found! [%s]\n"),p); bFind = TRUE; break;
}
} if (buffer) LocalFree(buffer); if (bFind) {
break;
}
} if ((GetLastError()!=NO_ERROR)&&(GetLastError()!=ERROR_NO_MORE_ITEMS))
{
printf("EnumDeviceInfo fail");
}
//
// Cleanup.
//
cleanup_DeviceInfo:
err = GetLastError();
SetupDiDeleteDeviceInfo(DeviceInfoSet, &DeviceInfoData); return err;
}