error LNK2019: unresolved external symbol __imp_SetupDiDestroyDeviceInfoList 错误解决

今天把以前代码中取电池信息的类,加入到com工程中。

结果报了Link错误。错误如下:

error LNK2019: unresolved external symbol __imp_SetupDiDestroyDeviceInfoList referenced in function "private: int __cdecl CNewPwrInfo::_EnumBatteryDevicePath(class std::vector<class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class std::allocator<class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t>> > > > &)" (?_EnumBatteryDevicePath@CNewPwrInfo@@AEAAHAEAV?$vector@V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@V?$allocator@V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@@std@@@std@@@Z)

error LNK2019: unresolved external symbol __imp_SetupDiEnumDeviceInterfaces referenced in function "private: int __cdecl CNewPwrInfo::_EnumBatteryDevicePath(class std::vector<class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class std::allocator<class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > > > &)" (?_EnumBatteryDevicePath@CNewPwrInfo@@AEAAHAEAV?$vector@V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@V?$allocator@V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@@std@@@std@@@Z)

error LNK2019: unresolved external symbol __imp_SetupDiGetClassDevsW referenced in function "private: int __cdecl CNewPwrInfo::_EnumBatteryDevicePath(class std::vector<class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class std::allocator<class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > > >&)" (?_EnumBatteryDevicePath@CNewPwrInfo@@AEAAHAEAV?$vector@V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@V?$allocator@V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@@std@@@std@@@Z)

error LNK2019: unresolved external symbol __imp_SetupDiGetDeviceInterfaceDetailW referenced in function "private: int __cdecl CNewPwrInfo::_GetDeviceDetailData(struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W * *,void * const,struct _SP_DEVICE_INTERFACE_DATA const *)" (?_GetDeviceDetailData@CNewPwrInfo@@AEAAHPEAPEAU_SP_DEVICE_INTERFACE_DETAIL_DATA_W@@QEAXPEBU_SP_DEVICE_INTERFACE_DATA@@@Z)


查找后发现是需要导入setupapi.lib

在工程属性 link中加入setupapi.lib就可。


阅读更多
上一篇WPF中更改Image控件的source
下一篇在installshield中如何创建service and 启动 停止 service
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭