Hi,
To work with shares you can use the WNetXXX functions provided in mpr.dll.
Here is an example using WNetGetConnection to determine what resource a
share is mapped to.
[DllImport("mpr.dll")]
public extern static short WNetGetConnection(
string lpLocalName,
StringBuilder lpRemoteName,
ref short lpnLength );
use it as follows
StringBuilder sb = new StringBuilder(256);
short len = 256;
short err = WNetGetConnection( "Z:", sb, ref len );
If 'Z:' in this case is a network share, sb will contain the path (assuming
the sb is big enough), other wise you will get an error, take a look in
WinError.h for the error numbers. ERROR_NOT_CONNECTED (2250) will be
returned if 'Z:' does not map to a network resource.
You can use WNetCancelConnection to delete a network share and
WNetAddConnection/2/3 to add a new share.
Hope this helps

Signature
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
> Given a path, is it possible to programatically determine if that path is a
> share, or an actuall directory?
> Then, if it is a share, how do I rename it? and how do I determine what
> directory it points to?
Michael Bray - 22 Jan 2004 23:38 GMT
> To work with shares you can use the WNetXXX functions provided in
> mpr.dll. Here is an example using WNetGetConnection to determine what
> resource a share is mapped to.
You can also enumerate the items returned by WMI's Win32_Share container.
This eliminates the need to do your own PInvoke (I would think that
System.Management WMI functions are just wrappers, but either way WMI is a
nice way to get this info.)
-mdb
Chris Taylor - 23 Jan 2004 05:10 GMT
Hi,
That is 100% correct. However, if I am not mistaken there is no way to
create shares using WMI, that is why I believe the WNet* functions are
required for this purpose.

Signature
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
> > To work with shares you can use the WNetXXX functions provided in
> > mpr.dll. Here is an example using WNetGetConnection to determine what
[quoted text clipped - 6 lines]
>
> -mdb
Jeremy Chapman - 23 Jan 2004 15:56 GMT
I got WMI to create a share. Thanks for the info guys.
> Hi,
>
[quoted text clipped - 12 lines]
> >
> > -mdb