How to fix a linker error with PKEY_Device_FriendlyName

后端 未结 3 1720
孤街浪徒
孤街浪徒 2020-12-21 10:37

Upon using PKEY_Device_FriendlyName, I\'m getting the following errors:

Error   1   error LNK2001: unresolved external symbol _PKEY_Device_FriendlyName Defau         


        
相关标签:
3条回答
  • 2020-12-21 11:20

    An updated solution that worked for me, as per the microsoft docs

    #include <functiondiscoverykeys.h>
    
    0 讨论(0)
  • 2020-12-21 11:28

    PKEY_Device_FriendlyName resides in uuid.lib library. So you need to add a line to your source code:

    #pragma comment(lib, "uuid.lib")
    

    Most often, you can check with MSDN which library you need to reference.

    0 讨论(0)
  • 2020-12-21 11:41

    Old post, but hopefully this answer will save someone some time.

    I was having the same problem with DEVPKEY properties - like DEVPKEY_Device_FriendlyName. I got a very similar link error. I stumbled upon the answer in comments here: Referencing GUIDs

    Basically, add an #include before the include for things like devpkey.h where the property keys are defined.

    So, at the top of my file I have:

    #include <setupapi.h>  
    #include <initguid.h>  // Put this in to get rid of linker errors.  
    #include <devpkey.h>  // Property keys defined here are now defined inline.   
    
    0 讨论(0)
提交回复
热议问题