是否可以使用 .NET 应用程序中的 IE 连接设置

发布于 2024-09-24 15:46:43 字数 416 浏览 0 评论 0原文

我有一个在 Windows 7 (x86) 上运行的 .NET 应用程序(WPF,但这并不重要)。我想从我的应用程序连接到互联网以调用网络服务。当有 wifi 连接时,我想使用它。如果没有 wifi 连接,我想自动连接到操作系统中定义的 GPRS 连接设置(例如,在 Internet Explorer 的连接设置中)。

在拨号时代,你可以在IE中同时指定LAN连接和拨号连接,当IE检测到没有LAN时,会询问你是否要连接到拨号。

在本例中,我使用 wifi 代替 LAN,使用 GPRS 代替拨号,并且我不使用 IE,而是使用自定义 .NET 应用程序。用操作系统对话框提示用户就可以了。

我可以使用托管 wlan API (codeplex) 和 GPRS 芯片组制造商的 SDK 自己完成此操作,但我想知道 Windows 7 是否可以通过某种方式为我完成此操作。

I have a .NET application (WPF but that doesn't really matter) running on Windows 7 (x86). I want to connect to the internet from my application to call a web service. When there is a wifi connection, I want to use that. If there is no wifi connection, I want to automatically connect to a GPRS connection setting defined in the OS (e.g. in internet explorer's connection settings).

In the days of dial-up, you could specify both a LAN connection and a dial-up connection in IE, and when IE detected that there was no LAN, you were asked if you wanted to connect to dial-up.

In this case, I have wifi instead of LAN and GPRS instead of dialup and I'm not using IE but a custom .NET application. Prompting the user with an OS dialog would be OK.

I can do this myself with the managed wlan API (codeplex) and the GPRS chipset manufaturer's SDK, but I want to know if there is a way that Windows 7 can do this for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ま昔日黯然 2024-10-01 15:46:43

使用 WebRequest 上可用的 DefaultWebproxy。 DefaultWebProxy 属性从 app.config 文件读取代理设置。如果没有配置文件,则使用当前用户的 Internet Explorer (IE) 代理设置。

例如-

webRequest.Credentials = CredentialCache.DefaultCredentials;
                    if (WebRequest.DefaultWebProxy != null)
                    {
                        webRequest.Proxy = WebRequest.DefaultWebProxy;
                        webRequest.Credentials = CredentialCache.DefaultCredentials;
                        webRequest.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
                    }
                    else
                    {
                        Trace.WriteLine("Unable to detect proxy.");
                    }

查看这些链接 -

  1. http:// msdn.microsoft.com/en-us/library/5t9y35bd.aspx
  2. http://msdn.microsoft.com/en-us/library/system.net.webrequest.defaultwebproxy.aspx
  3. http://msdn.microsoft.com/en-us/magazine/cc300743.aspx

Use DefaultWebproxy available on a WebRequest. The DefaultWebProxy property reads proxy settings from the app.config file. If there is no config file, the current user's Internet Explorer (IE) proxy settings are used.

For Ex-

webRequest.Credentials = CredentialCache.DefaultCredentials;
                    if (WebRequest.DefaultWebProxy != null)
                    {
                        webRequest.Proxy = WebRequest.DefaultWebProxy;
                        webRequest.Credentials = CredentialCache.DefaultCredentials;
                        webRequest.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
                    }
                    else
                    {
                        Trace.WriteLine("Unable to detect proxy.");
                    }

Check out these links -

  1. http://msdn.microsoft.com/en-us/library/5t9y35bd.aspx
  2. http://msdn.microsoft.com/en-us/library/system.net.webrequest.defaultwebproxy.aspx
  3. http://msdn.microsoft.com/en-us/magazine/cc300743.aspx
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文