开发者

Get IP Adress from a connected Windows Network Share with Python

开发者 https://www.devze.com 2023-01-07 03:11 出处:网络
How can i manage to get the IP or path like \\11.1.1.100\\projects of a connected network share with a drive letter.

How can i manage to get the IP or path like \11.1.1.100\projects of a connected network share with a drive letter. I only have the drive letter and want to get the IP of the Share with python. Many Thanks... Sashmo开发者_如何学Python


I don't know the python equivalent, but WNetGetConnection will give you the UNC path mapped to the drive letter:

wchar_t szName[256];
DWORD chName = 256;
DWORD dwResult = WNetGetConnectionW(L"Z:", szName, &chName);

I'm sure there is a python module that wraps this functionality. From the UNC path you can get the server name, and from that you can lookup its IP address.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号