Tim Golden wrote:
Stef Mientki wrote:
AFAIK it's not allowed to connect a network share more than once.
As my shares can already be connected through by another program,
I need to detect if a network share is already connected,
So I try to get a list of available network shares,
but I don't see the network shares, although they are available.

There's usually a bit of confusion around the term "network share".
In the case of WMI, it refers to the shares which are exposed / exported
by the machine in question. (In your example, the local machine).

If you actually want the list of (remote or local) shares to which
you have connected, you want Win32_MappedLogicalDisk or Win32_LogicalDisk,
depending on your precise requirements:

<code>
import wmi

c = wmi.WMI ()

share_to_connect_to = r"\\handel\public"
for d in c.Win32_MappedLogicalDisk (
 ProviderName=share_to_connect_to
):
 print "Already mapped to", d.Caption
 break
else:
 print "Not mapped"

</code>

However... it's perfectly possible to connect to the
same share several times so I think you're working
from a faulty premise. However, I hope the above
is informative even if not so necessary.

thanks Tim,
You're right about making more connections to the same network share,
it is possible.
I was confused because in another program, it wasn't allowed,
probably because I wanted to connect it with a different user/pwd.

The above code was informative,
but didn't answer my needs.
I guess the question was not precise enough,
I wanted to test connection to share, that are not "mounted" ? to a logical drive letter,
like this connection:
       Result = win32wnet.WNetAddConnection2 (
         dwType, lpLocalName, lpRemoteName, lpProvider,
         lpUsername, lpPassword, dwFlags )
These connections don't show with the given code.

But the major fact is that the problem is solved, Thanks again.

cheers,
Stef
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to