UWP c++ winrt 应用程序显示 SHGDNF 在 ShObjldl_core.h 中未被识别

UWP c++ winrt app shows SHGDNF is unidentified in ShObjldl_core.h

我正在将 c# .netcore 应用程序移动到 UWP 桌面桥。我能够部署和构建应用程序,但是在添加 c++ winrt 组件时,我收到一条错误消息,指出 SHGDNF 在 ShObjldl_core.h 中未被识别,下面是 pch.cpp

`#pragma once
#include <stdio.h>

#include <tchar.h>

#include <Unknwn.h>

#include <winrt/base.h>

#include <shlwapi.h>
#include <pathcch.h>

#include <ShlGuid.h>

#include <ShObjIdl_core.h>

#include <ShlObj_core.h>

#include <cfapi.h>

#include <ntstatus.h>

#include <sddl.h>

#include <winrt\windows.storage.provider.h>

#include <winrt\Windows.Security.Cryptography.h>

#include <ppltasks.h>

#include <strsafe.h>`

您可以在 ShObjIdl_core.h 上按 F12 来查看文档,您会看到有一个 #if 语句 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 说header 文件可用于 Desktop Win32 应用程序(但不适用于商店应用程序)。 C++/Winrt 组件项目不是 Win32 应用程序,因此,ShObjIdl_core.h header 无法在项目中使用。