SetupDiGetDeviceInterfaceDetail 错误返回值为122

yinwjvip_2012 2013-07-30 11:22:16
hardwareDeviceInfoSet是已经正确获得的值
deviceInterfaceData的值设置为
deviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
//此处大小为32字节,系统是64位的win7

SetupDiEnumDeviceInterfaces (hardwareDeviceInfoSet, NULL, //infoData, &hidGUID, //interfaceClassGuid, deviceIndex, &deviceInterfaceData);
这个函数成功执行

SetupDiGetDeviceInterfaceDetail (hardwareDeviceInfoSet, &deviceInterfaceData, NULL, //interfaceDetail, 0, //interfaceDetailSize, &requiredSize, 0); //infoData))
这个函数失败返回值 为122,该怎么解决呀
...全文
275 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
davidyu720 2013-07-31
  • 打赏
  • 举报
回复
返回122是正确的呀,此时requiredSize里面有正确的值。然后你分配requiredSize大小的buffer,再次调用SetupDiGetDeviceInterfaceDetail 即可。 http://msdn.microsoft.com/zh-cn/ff551120 Using this function to get details about an interface is typically a two-step process: 1.Get the required buffer size. Call SetupDiGetDeviceInterfaceDetail with a NULLDeviceInterfaceDetailData pointer, a DeviceInterfaceDetailDataSize of zero, and a valid RequiredSize variable. In response to such a call, this function returns the required buffer size at RequiredSize and fails with GetLastError returning ERROR_INSUFFICIENT_BUFFER. 2.Allocate an appropriately sized buffer and call the function again to get the interface details.
davidyu720 2013-07-30
  • 打赏
  • 举报
回复
122 : 传递给系统调用的数据区域太小。
yinwjvip_2012 2013-07-30
  • 打赏
  • 举报
回复
是的,我看了参数,也看不出来有什么不对的地方,系统是64位的

64,674

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧