如何检索所有 RAS 连接?

发布于 2024-12-29 02:26:47 字数 190 浏览 2 评论 0原文

我想要获取“控制面板”下“网络连接”中显示的所有 RAS 连接(拨号、宽带、VPN 等)。这里和网络上有一些解决方案可以做到这一点,但它们都是关于获取活动(连接)连接

我该怎么做?如何获取所有活动和非活动 RAS 连接?有或没有“DotRas”。

I want to get all RAS connections (Dial-up, Broadband, VPN, etc.) as they appear in my "Network Connections" under "Control Panel". There are some solutions here and on the web to do this, but they are all about getting Active (connected) Connections.

How can I do this? How can I get all active and inactive RAS connections? With or without "DotRas".

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

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

发布评论

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

评论(2

來不及說愛妳 2025-01-05 02:26:47

DotRas SDK 中有一个组件用于处理电话簿条目的管理。请记住,Windows 使用两本电话簿,一本位于所有用户的配置文件中,另一本位于当前用户的配置文件中。因此,如果您想获取在那里看到的所有条目的列表,则需要访问两个电话簿。

using DotRas;

RasPhoneBook pbk = new RasPhoneBook();
pbk.Open(@"C:\PathToYourPhoneBook.pbk");

// NOTE: You can also use RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers) to 
// access the path as defined by the Windows SDK rather than having to hard-code it.

foreach (RasEntry entry in pbk.Entries)
{
    // Do something useful.
}

上面的示例相当有限,因此要获得更完整的示例,请查看 SDK 中包含的示例。

有关上述 SDK 的下载链接,请参阅官方网站:http://dotras.codeplex.com

希望有帮助!

There is a component as part of the DotRas SDK which handles management of the phone book entries. Keep in mind that there are two phone books in use by Windows, the one in the all users' profile and the current users' profile. So if you're trying to get a list all the entries that you'd see there, you'd need to access both phone books.

using DotRas;

RasPhoneBook pbk = new RasPhoneBook();
pbk.Open(@"C:\PathToYourPhoneBook.pbk");

// NOTE: You can also use RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers) to 
// access the path as defined by the Windows SDK rather than having to hard-code it.

foreach (RasEntry entry in pbk.Entries)
{
    // Do something useful.
}

The above example is rather limited so for more complete examples check the examples included with the SDK.

For a download link to the above mentioned SDK, see the official website at: http://dotras.codeplex.com

Hope that helps!

忆伤 2025-01-05 02:26:47

如果你想动态获取所有 RAS 连接而不需要 .pbk 文件“路径”

using DotRas;

string path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers);
RasPhoneBook pbk = new RasPhoneBook();
pbk.Open(path);

foreach (RasEntry entry in pbk.Entries)
{
  MessageBox.Show(entry.Name);
}

if you want dynamically get all RAS connection without .pbk file "path"

using DotRas;

string path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers);
RasPhoneBook pbk = new RasPhoneBook();
pbk.Open(path);

foreach (RasEntry entry in pbk.Entries)
{
  MessageBox.Show(entry.Name);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文