首先,我在 Win32/C++ 项目中通过“Windows 应用程序打包项目”使用 WinRT::MiracastReceiver(Win10 sdk)。 https://docs.microsoft.com/zh-tw/windows/msix/desktop/desktop-to-uwp-packaging-dot-net。所以它已经有包标识(私有网络和互联网 C/S 能力)。
我检查了这个 API 有 DualApiPartition 属性,所以桌面应用程序可以调用 WinRT API。 https://docs.microsoft.com/zh-tw/windows/win32/apiindex/uwp-apis-callable-from-a-classic-desktop-app
当我启动 MiracastReceiver 会话时,我得到 MiracastNotSupported 的结果?我该如何解决这个问题?
当我将相同的代码放入 WinRT/UWP 项目时,它是成功的。
int main()
{
winrt::init_apartment();
receiver_ = MiracastReceiver();
receiver_.StatusChanged( {&OnStatusChanged} );
MiracastReceiverSettings settings = receiver_.GetDefaultSettings();
settings.FriendlyName(L"MiracastReceiver.2020.1217");
settings.AuthorizationMethod(MiracastReceiverAuthorizationMethod::None);
settings.ModelName(receiver_.GetDefaultSettings().ModelName());
settings.ModelNumber(receiver_.GetDefaultSettings().ModelNumber());
settings.RequireAuthorizationFromKnownTransmitters(false);
auto settings_sts = receiver_.DisconnectAllAndApplySettings(settings);
session_ = receiver_.CreateSession(nullptr);
session_.AllowConnectionTakeover(true);
session_.ConnectionCreated( {&OnConnectionCreated} );
session_.Disconnected( {&OnDisconnected} );
session_.MediaSourceCreated( {&OnMediaSourceCreated} );
MiracastReceiverSessionStartResult result = session_.Start();
MiracastReceiverSessionStartStatus status = result.Status();
std::wostringstream message;
message << L"ClickHandler: session_.Start, status=" << (int)status << std::endl;
OutputDebugString(message.str().c_str());
system("PAUSE");
}
状态 = MiracastNotSupported
环境:
- Visual Studio 2017 v15.9.30
- Win10 SDK 10.0.19041.0
- Win10 操作系统 2004 (19041)