确定网络驱动器的协议

确定网络驱动器的协议

本文介绍了确定网络驱动器的协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以确定用于Windows上已安装的网络驱动器的协议名称(SMB/CIFS,NFS)和版本? (在C#中)

Is there a way to determine the protocol name (SMB/CIFS,NFS) and version that is used for a mounted network drive on windows? (in C#)

编辑

使用Rusted的答案中的信息,我从网络上的Windows 7计算机中获得了以下信息.

Using info from Rusted's answer, i got the following information from a windows 7 computer on the network.

NETRESOURCE res = WinApiWNETwrapper.GetResourceInfo("\\Test-PC");

res.dwDisplayType = SERVER
res.dwScope       = 0
res.dwType        = ANY
res.dwUsage       = CONTAINER
res.lpComment     = ""
res.lpLocalName   = null
res.lpProvider    = "Microsoft Windows Network"
res.lpLocalName   = "\\Test-PC"

NETINFOSTRUCT netinfo = WinApiWNETwrapper.GetNetworkInfo("\\Test-PC");

netinfo.cbStructureSize   = 32
netinfo.dwCharacteristics = 0
netinfo.dwDrives          = -1
netinfo.dwHandle          = 1880621056
netinfo.dwPrinters        = -1
netinfo.dwProviderVersion = 1024
netinfo.dwStatus          = Running
netinfo.wNetType          = LANMAN

SERVER_TRANSPORT_INFO_1[] transports = WinApiNETwrapper.ServerTransportEnum_1("\\Test-PC");

transports[0].svti1_domain                 = "WORKGROUP"
transports[0].svti1_networkaddress         = "TEST-PC"
transports[0].svti1_numberofvcs            = 0
transports[0].svti1_transportaddress       = 73107336
transports[0].svti1_transportaddresslength = ...
transports[0].TransportAddress             = "TEST-PC"

transports[0].svti1_transportname          = "\\Device\\NetbiosSmb"
transports[1].svti1_transportname          = "\\Device\\NetBT_Tcpip_{F4C75115-...}"
transports[2].svti1_transportname          = "\\Device\\NetBT_Tcpip_{70BD9048-...}"

重要的部分似乎是:

transports[0].svti1_transportname          = "\\Device\\NetbiosSmb"

但是我在任何地方都找不到SMB协议的版本号.有什么想法吗?

But i cannot find the version number of the SMB protocol anywhere. Any ideas?

推荐答案

我想您需要 Windows网络(WNet)API ,它是 NETINFOSTRUCT WNetGetNetworkInformation 函数.

I suppose you've need the Windows Networking (WNet) API, a value from NetType field in NETINFOSTRUCT returned by WNetGetNetworkInformation function.

此处是C#中的开源项目,请检查文件夹.

Here is open-source project in C#, check files in WnetApi folder for .NET wrappers for Wnet API.

要获取映射驱动器的UNC路径,请使用此中的PathToUNC方法项目.

To get the UNC path for a mapped drive use PathToUNC method from this project.

这篇关于确定网络驱动器的协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 14:54