如何在 C++ 中找到映射网络驱动器的 IP 地址?

发布于 2024-09-15 06:37:27 字数 389 浏览 2 评论 0原文

我有一个可用于默认输入数据目录的可能路径列表(X:\Data; Y:\Data; Z:\Data)。所有可能的路径都映射到网络驱动器。我可以使用 GetDriveType(pathStr) == DRIVE_REMOTE 来检查这一点。为了确定最佳路径,我通过仅选择存在的路径来缩小列表范围。有时列表中会留下多个路径,因此为了确定此时最好的一条路径,我想找到驱动器映射到的服务器的 IP 地址,这样我可以将其与我自己的 IP 地址进行比较。例如,如果我将 X:\ 映射到 \\RemoteComputer\ShareName,我如何从字符串 X:\Data 中找到RemoteComputer 的名称或 IP 地址? (我已经能够从计算机名称中找到IP地址)。

I have a list of possible paths to use for a default input data directory (X:\Data; Y:\Data; Z:\Data). All of the possible paths are mapped network drives. I can check this using GetDriveType(pathStr) == DRIVE_REMOTE. To determine the best one, I have narrowed down the list by selecting only paths that exist. Sometimes there will be more than one path left in the list, so to determine the best one at that point, I want to find the IP address of the server that the drive is mapped to, so I can compare it to my own IP address. For instance, if I have X:\ mapped to \\RemoteComputer\ShareName, how can I find out from the string X:\Data either the name or IP address of RemoteComputer? (I already have the ability to find the IP address from a computer name).

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

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

发布评论

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

评论(2

请恋爱 2024-09-22 06:37:27

WNetGetUniversalName 是一种可能性。

WNetGetUniversalName is one possibility.

只有一腔孤勇 2024-09-22 06:37:27

请记住,并非所有(但绝大多数)UNC 路径都以计算机名称开头。有些像 WebDav 是 FQDN,有些像 TS remoting(即 \tsclient\c)根本​​不是机器,只是 RDBSS 识别的令牌。

Keep in mind, that not all (but the vast majority) of UNC paths start with a computer name. Some like WebDav, are a FQDN - others like TS remoting (i.e. \tsclient\c) aren't a machine at all, just a token that RDBSS recognizes.

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