Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#在热点中获取客户端_C#_Uwp_Tethering - Fatal编程技术网

C#在热点中获取客户端

C#在热点中获取客户端,c#,uwp,tethering,C#,Uwp,Tethering,我已经用C语言编写了一个应用程序,可以在Windows中打开和关闭移动热点。我的项目还需要其他有用的功能 今天,我的目标是创建一个我当前连接设备的列表,但我还没有通过谷歌完成 我不知道如何显示连接设备的MAC地址和名称。有人有主意吗 我在Microsoft文档中找到了此页,但不幸的是,它对我没有任何帮助。 我是C语言的初学者,所以请不要生气:) 不起作用的基本代码: var tetheringManager = Windows.Networking.NetworkOperators.Netwo

我已经用C语言编写了一个应用程序,可以在Windows中打开和关闭移动热点。我的项目还需要其他有用的功能

今天,我的目标是创建一个我当前连接设备的列表,但我还没有通过谷歌完成

我不知道如何显示连接设备的MAC地址和名称。有人有主意吗

我在Microsoft文档中找到了此页,但不幸的是,它对我没有任何帮助。

我是C语言的初学者,所以请不要生气:)

不起作用的基本代码:

var tetheringManager = Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager.CreateFromConnectionProfile(connectionProfile);

                    var clientCount = tetheringManager.ClientCount;
                    ClientCount(clientCount);
                    var maxClientCount = tetheringManager.MaxClientCount;
                    MaxClientCount(maxClientCount);

                    var currentClients = tetheringManager.GetTetheringClients().ToArray(); // NOT WORKING
                    foreach(var client in currentClients)
                    {
                        MessageBox.Show(client.ToString());
                    }

我已将此库重新用于我的项目:

C#在热点中获取客户端

显示的消息框表示,您已经获得了
TetheringClient
。但不能直接使用字符串。您需要创建一个新类来存储客户端主机名和mac地址

var currentClients = tetheringManager.GetTetheringClients(); 
foreach (var client in currentClients)
{
    var cilentinfo = new ClientInfo()
    {
        DisplayName = client.HostNames[0].DisplayName,
        MacAddress = client.MacAddress
    };
    client.ToString();
}

public class ClientInfo
{
    public string DisplayName { get; set; }
    public string MacAddress { get; set; }

    public override string ToString()
    {
        return DisplayName + MacAddress;
    }
}