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 std::allocator> > > > &)" (?_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 std::allocator > > > > &)" (?_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 std::allocator > > > >&)" (?_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就可。


你可能感兴趣的:(error LNK2019: unresolved external symbol __imp_SetupDiDestroyDeviceInfoList 错误解决)