0

I am trying to get a list of all attached devices in a Windows OS. The only relevant article I could find was this.

Following the instructions listed there I created a small program:

#include "stdafx.h"
#include "PortableDeviceApi.h"
#include <atlbase.h>
int main()
{
       CComPtr<IPortableDeviceManager>  pPortableDeviceManager;

       HRESULT hr = CoCreateInstance(CLSID_PortableDeviceManager,
          NULL,
          CLSCTX_INPROC_SERVER,
          IID_PPV_ARGS(&pPortableDeviceManager));
       if (FAILED(hr))
       {
              printf("! Failed to CoCreateInstance CLSID_PortableDeviceManager, hr = 0x%lx\n", hr);
       }
    return 0;
}

However, it throws the following error: LNK2001 unresolved external symbol _CLSID_PortableDeviceManager

Any suggestions as to how I can resolve this error?

Thanks!

JayHawk
  • 275
  • 1
  • 5
  • 15
  • 1
    Add the required library from here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd388688(v=vs.85).aspx Also you are going to need to initialise COM. – Richard Critten Jun 08 '18 at 00:14
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White Jun 08 '18 at 00:17

0 Answers0