简体   繁体   English

有没有办法以编程方式关闭C#中的WiFi

[英]Is there a way to programmatically turn OFF WiFi in C#

But in such a way that there is absolutely NO TRANSMISSION out of it? 但是,以这种方式绝对没有传输吗? No searching for hotspots nor any keepalives or any other transmission? 无需搜索热点,没有保持活动或任何其他传播方式?

Thank you very much, Yaron. 非常感谢Yaron。

You can check the How to use the connection settings task for Windows Phone 8 . 您可以选中“ 如何使用Windows Phone 8的连接设置”任务 You can use the 您可以使用

var navigate = Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-location:"));

which will navigate you to the settings page where you can turn off and on the wifi settings. 它将带您进入设置页面,您可以在其中关闭和打开wifi设置。

You can't change them programmatically, but you can ask a user to change them and redirect a user to the Settings page (for this purpose use ConnectionSettingsTask http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394011(v=vs.105).aspx ). 您无法通过编程方式更改它们,但可以要求用户更改它们并将用户重定向到“ Settings页面(为此,请使用ConnectionSettingsTask http://msdn.microsoft.com/zh-cn/library/windowsphone/develop /hh394011(v=vs.105).aspx )。

This is because the platform leaves these kinds of settings in the user's control at all times. 这是因为平台始终将这些类型的设置留在用户的控件中。

ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
connectionSettingsTask.Show();

The closest you can get is to programmatically launch the WiFi settings page where the user can modify the setting: 您能获得的最接近的结果是以编程方式启动WiFi设置页面,用户可以在其中修改设置:

await Launcher.LaunchUriAsync(new Uri("ms-settings-wifi:"));

In Windows 10 you can use this API 在Windows 10中,您可以使用此API

There is a sample of its usage published by Microsoft here Microsoft 此处发布了其用法示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM