为什么我得到LNK2001未解析的符号_IID_IPortableDeviceManager

时间:2016-07-18 15:06:58

标签: c

我正在尝试使用C枚举连接的设备,并在Windows 10上使用VS 2015编写代码。

我的头文件如下所示:

#pragma once

#include <PortableDeviceApi.h>
#include <stdio.h>
#include <objbase.h>

/*
Asks the user what registry key he would like to get and then output the key to a file.

@param - None
@return - None
*/
void showDevices();

我的源代码如下所示:

#include "DeviceHandler.h"

void showDevices()
{

    IPortableDeviceManager *deviceManager;
    HRESULT result;
    IID const *interfaceId =  &IID_IPortableDeviceManager;
    CLSID const *classId = &CLSID_PortableDeviceManager;

    deviceManager = malloc(sizeof(IPortableDeviceManager));

    result = CoCreateInstance(classId, NULL, CLSCTX_INPROC_SERVER, interfaceId, &deviceManager);

    if (result != S_OK)
    {
        wprintf(L"%s\n", L"Class failed to be created");
    }

    free(deviceManager);

    return;
}//end showDevices

我收到IID_IPortableDeviceManager和CLSID_PortableDeviceManager的链接错误。

我查看了包含的PortableDeviceApi.h文件,这两个变量定义为:

EXTERN_C const CLSID CLSID_PortableDeviceManager;
EXTERN_C const IID IID_IPortableDeviceManager;

我需要做些什么才能让链接器识别这些外部变量?

0 个答案:

没有答案