2017-12-08 64 views
0

自分のマシンに接続されているデバイスの場合、デバイスプロパティバスの報告されたデバイスの説明を取得します。この目的のために私はSetup APIの機能SetupDiGetDevicePropertyを使用します。 devpkey.hで定義が見つかりましたDEVPKEY_Device_BusReportedDeviceDescです。未解決の外部シンボル_DEVPKEY_Device_BusReportedDeviceDesc

しかし、私はDEVPKEY_Device_BusReportedDeviceDescを使用する場合は、リンク中、私は_DEVPKEY_Device_BusReportedDeviceDesc未解決の外部シンボルを受け取ります。ここで

は私のコードは(唯一の問題を再現する最小限のコードを含む)である:

エラーLNK2001:未解決の外部シンボル _DEVPKEY_Device_BusReportedDeviceDesc

ここ

#include "stdafx.h" 

#include <Windows.h> 
#include <devpropdef.h> 
#include <devpkey.h> 

int main() 
{ 
    DEVPROPKEY x = DEVPKEY_Device_BusReportedDeviceDesc; 

    return 0; 
} 

は、完全なエラーコードです

この問題を解決するにはどうすればよいですか?

答えて

0

この問題を解決するには、initguid.hを含める必要があります。このインクルードは、の前に必要です。devpropdef.hdevpkey.h

#include "stdafx.h" 
#include <initguid.h> // include before devpropdef.h 
#include <Windows.h> 
#include <devpropdef.h> 
#include <devpkey.h> 

int main() 
{ 
    DEVPROPKEY x = DEVPKEY_Device_BusReportedDeviceDesc; 

    return 0; 
}