[英]Connect And Disconnect Mobile Broadband Connection
请告诉我如何使用C#或DOS连接和断开移动宽带连接?
On the commandline (DOS) you can use the netsh command. 在命令行(DOS)上,您可以使用netsh命令。
Instructions: 1) Get the mobile interface and note the name 说明:1)获取移动界面并记下名称
netsh mbn show interface
Output: 输出:
There is 1 interface on the system:
Name : Mobiel 5
Description : Sierra Wireless EM7345 4G LTE
GUID : xxx
Physical Address : xxx
State : Not connected
Device type : Mobile Broadband device is embedded in the system
Cellular class : GSM
Device Id : xxx
Manufacturer : Sierra Wireless Inc.
Model : Sierra Wireless EM7345 4G LTE
Firmware Version : FIH7160_V1.2_WW_01.1442.11
Provider Name : BEL PROXIMUS
Roaming : Yes
Signal : 74%
RSSI / RSCP : 23 (-67 dBm)
2) Get the connection profiles for the interface (on my system the name is "mobiel 5" 2)获取接口的连接配置文件(在我的系统上名称为“mobiel 5”
netsh mbn show profiles interface="mobiel 5"
Output 产量
Profiles on interface Mobiel 5:
-------------------------------------
{3623E7AB-E116-47E6-8A9B-FCC1ADBE568E}
{F4E77FAE-D4FD-4196-86CA-852EFE8A9154}
!!##MBIMModemProvisionedContextInternetProfile##8935299564103228197
3) Connect using the interface and profile name 3)使用界面和配置文件名称进行连接
netsh mbn connect interface="mobiel 5" connmode=name name="{F4E77FAE-D4FD-4196-86CA-852EFE8A9154}"
4) Disconnect using the interface name 4)使用接口名称断开连接
netsh mbn disconnect interface="mobiel 5"
This works on Windows 10 这适用于Windows 10
There is no native support in .NET, you need to invoke the win api, specifically wininet.dll
and invoke InternetGetConnectedState function . 在.NET中没有本机支持,您需要调用win api,特别是
wininet.dll
并调用InternetGetConnectedState函数 。 You can use the following link for with a sample code. 您可以使用以下链接获取示例代码。 Code is in VB, but you can easily convert it to c# .
代码在VB中,但您可以轻松地将其转换为c# 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.