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
--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
"Jeremy Chapman" <NoS...@Please.com> wrote in message
news:uPyfFLw2...@TK2MSFTNGP10.phx.gbl...
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
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.
--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
"Michael Bray" <mbrayXXnoS...@SkPiAlMl.ctiusa.com> wrote in message
news:Xns9478BD9E4B23Cmb...@207.46.248.16...
"Chris Taylor" <chris_t...@hotmail.com> wrote in message
news:OIkX$8W4DH...@TK2MSFTNGP12.phx.gbl...