Windows.Devices.Enumeration DeviceWatcher找不到具有多个网卡的所有服务

时间:2018-12-17 17:28:17

标签: c++ uwp dns-sd

我在Windows.Devices.Enumeration及其带有DN-SD和C ++ / WinRT的DeviceWatcher时遇到问题。 我的机器中有2个网卡,仅找到通过第一个网卡连接的机器上的那些服务。

这既在我自己的测试程序中发生,又在我扩展Microsoft“ Windows Universal Samples”中的DeviceEnumeration示例程序以包括DNS-SD时发生。在Samples / DeviceEnumerationAndPairing / cpp / DisplayHelpers.h中添加到DeviceSelectorChoices。

static property DeviceSelectorInfo^ Dnssd
{
    DeviceSelectorInfo^ get();
}

并插入Samples / DeviceEnumerationAndPairing / cpp / DisplayHelpers.cpp插入

DeviceSelectorInfo^ DeviceSelectorChoices::Dnssd::get()
{
    return ref new DeviceSelectorInfo("DNS-SD",
        DeviceClass::All,
        "System.Devices.AepService.ProtocolId:=\"{4526e8c1-8aac-4153-9b16-55e86ada0e54}\" "
        "AND System.Devices.Dnssd.ServiceName:=\"_myservice._tcp\"",
        DeviceInformationKind::AssociationEndpointService);
}

到Samples / DeviceEnumerationAndPairing / cpp / DisplayHelpers.cpp并更新方法:

IVectorView<DeviceSelectorInfo^>^ DeviceSelectorChoices::DeviceWatcherSelectors::get()
{
    Vector<DeviceSelectorInfo^>^ selectors = ref new Vector<DeviceSelectorInfo^>(begin(CommonDeviceSelectors), end(CommonDeviceSelectors));
    selectors->Append(Dnssd);
    ...

然后编译并运行并从设备监视程序中选择DNS-SD-它仅在第一个网络接口的子网上有连接的机器上查找服务,即使它在第二个网络的子网上有连接也是如此。但是它没有列出仅在第二个网络上的机器上运行的任何服务。

使用dns-sd命令行工具可以找到两个网络上所有已发布的服务:

dns-sd -B _myservice._tcp

我已经尝试过AQSFilter的许多变体,认为它可能不是默认使用两个网络接口-例如使用System.Devices.Dnssd.NetworkAdapterId-却不高兴。

我猜想它在Windows中比设备枚举API还要低的可能性。?

0 个答案:

没有答案
相关问题