如何在C ++中找到映射的网络驱动器的IP地址? [英] How can I find the IP address of a mapped network drive in C++?

查看:371
本文介绍了如何在C ++中找到映射的网络驱动器的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个默认输入数据目录(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).

推荐答案

WNetGetUniversalName is one possibility.

这篇关于如何在C ++中找到映射的网络驱动器的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆