简体   繁体   English

如何使用IShellFolder检测映射的网络驱动器是否已断开连接?

[英]How detect if mapped network drive is disconnected using IShellFolder?

I am using the IShellFolder interface to enumermate the Shell namespace objects. 我正在使用IShellFolder接口枚举Shell名称空间对象。 Doing this I am getting my mapped network drives, of which some are connected and available and others are not. 这样做,我得到了映射的网络驱动器,其中一些已连接并且可用,而另一些则没有。

I would to know how I can detect whether or not a particular mapped drive is available. 我想知道如何检测特定的映射驱动器是否可用。 Is there some method, shell function or attribute that I can use? 我可以使用某些方法,shell函数或属性吗?

I am using IShellFolder.GetAttributesOf() method to get various attributes on the drive, but do not see anything there that would indicate this. 我正在使用IShellFolder.GetAttributesOf()方法来获取驱动器上的各种属性,但是看不到任何表明该情况的信息。

If a mapped drive is disconnected it will not appear in the bitmask returned by the GetLogicalDrives function. 如果映射的驱动器断开连接,它将不会出现在GetLogicalDrives函数返回的位掩码中。

For example, 例如,

wchar_t wchDriveLetter = L'P'; // example
int iDriveNumber = towupper(wchDriveLetter) - L'A';
bool fIsDisconnected = ( GetLogicalDrives() & ( 1 << iDriveNumber ) ) == 0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM