如何防止新连接出现网络位置对话框(家庭、工作、公共)?
我编写了一个软件,如果连接尚不存在,则使用 USB 3G 适配器连接到互联网。
当软件加载时,它会检测互联网是否可用,如果不可用,则创建拨号连接(通过 RAS),然后进行拨号。
如果第一次发生这种情况,则会出现网络位置对话框,要求用户选择是家庭、工作还是公共网络。
无论如何,我可以以编程方式设置连接的网络位置,或者甚至告诉 Windows 不要显示对话框并自动将位置设置为公共?
干杯
加文
编辑:为斯科特M
public bool Connect(bool monitorSignalUpdates)
{
RasPhoneBook rpb = new RasPhoneBook();
rpb.Open(true);
if (!rpb.Entries.Contains("3G Connection"))
{
rpb.Entries.Add(RasEntry.CreateBroadbandEntry("3G Connection", RasDevice.GetDeviceByName("HUAWEI Mobile Connect - 3G Modem", RasDeviceType.Modem), true));
}
_rd = new RasDialer();
_rd.EntryName = "3G Connection";
_rd.PhoneNumber = "*99#";
try
{
_rd.Dial();
if (monitorSignalUpdates)
{
_queryPort.DataReceived += new SerialDataReceivedEventHandler(_queryPort_DataReceived);
}
return true;
}
catch (Exception ex)
{
int i = 99;
}
return false;
}
I've written a piece of software that uses an USB 3G Dongle to connect to the internet if a connection doesn't already exist.
When the software loads, it detects whether the internet is available and if not, then creates a dial up connection (via RAS) and then dials it.
If this happens for the first time, the network location dialog comes up asking the user to select whether it's home, work or public.
Is there anyway, I can either programatically set the network location of a connection, or even tell windows not to show the dialog and automatically set the location to public?
Cheers
Gavin
Edit: For ScottM
public bool Connect(bool monitorSignalUpdates)
{
RasPhoneBook rpb = new RasPhoneBook();
rpb.Open(true);
if (!rpb.Entries.Contains("3G Connection"))
{
rpb.Entries.Add(RasEntry.CreateBroadbandEntry("3G Connection", RasDevice.GetDeviceByName("HUAWEI Mobile Connect - 3G Modem", RasDeviceType.Modem), true));
}
_rd = new RasDialer();
_rd.EntryName = "3G Connection";
_rd.PhoneNumber = "*99#";
try
{
_rd.Dial();
if (monitorSignalUpdates)
{
_queryPort.DataReceived += new SerialDataReceivedEventHandler(_queryPort_DataReceived);
}
return true;
}
catch (Exception ex)
{
int i = 99;
}
return false;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此注册表项控制 Windows 是否提示(“Home/Work/Public”):
HKLM\System\CurrentControlSet\Control\Network\NewNetworkWindowOff
http://technet.microsoft.com/en-us/library/gg252535%28v=ws.10%29.aspx
您可以随时“关闭新网络上的通知”系统托盘 :)
如果你能做到这一点,我确信有一个注册表黑客和/或 PowerShell API 可以做到这一点:
http://technet.microsoft.com/en-us /library/cc725831%28v=ws.10%29.aspx
This registry entry controls whether Windows will prompt for ("Home/Work/Public"):
HKLM\System\CurrentControlSet\Control\Network\NewNetworkWindowOff
http://technet.microsoft.com/en-us/library/gg252535%28v=ws.10%29.aspx
You can always "“Turn off Notification on New Networks” from system tray :)
And if you can do that, I'm sure there's a registry hack and/or a PowerShell API for doing the same:
http://technet.microsoft.com/en-us/library/cc725831%28v=ws.10%29.aspx