@msdn=http://msdn.microsoft.com/en-us/library/windows/desktop/bb525385%28v=VS.85%29.aspx @pinvoke=http://pinvoke.net/$$$.htm Summary: Checks whether or not a server is sharing a device. !!!!C# Signature: [DllImport("netapi32.dll", SetLastError=true)] static extern uint NetShareCheck( [MarshalAs(UnmanagedType.LPWStr)] string servername, [MarshalAs(UnmanagedType.LPWStr)] string device, out SHARE_TYPE type ); !!!!VB Signature: Declare Function NetShareCheck Lib "netapi32.dll" (TODO) As TODO !!!!C# User-Defined Types: private enum NetError : uint { NERR_Success = 0, ERROR_NOT_ENOUGH_MEMORY = 8, NERR_DeviceNotShared = 2311, } private enum SHARE_TYPE : uint { STYPE_DISKTREE = 0, STYPE_PRINTQ = 1, STYPE_DEVICE = 2, STYPE_IPC = 3, STYPE_TEMPORARY = 0x40000000, STYPE_SPECIAL = 0x80000000, } !!!!VB User-Defined Types: TODO !!!!Alternative Managed API: Do you know one? Please contribute it! !!!!Notes: None. !!!!Tips & Tricks: '''Parameters''' *servername: String that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used. *device: String that specifies the name of the device to check for shared access. Drive letter must be upper case. *type: Specify the type of the shared device. This parameter is set only if the function returns successfully. !!!!C# Sample Code: String server = "myServer"; // could be empty for local computer String localPath = @"C:\shared folder"; SHARE_TYPE shareType; Boolean exists; NetError result = (NetError)NetShareCheck(server, localPath, out shareType); switch (result) { case NetError.NERR_Success: exists = true; break; case NetError.ERROR_NOT_ENOUGH_MEMORY: throw new OutOfMemoryException(); case NetError.DeviceNotShared: exists = false; break; } !!!!VB Sample Code: Please add some! Documentation: NetShareCheck@msdn on MSDN
Edit netapi32.NetShare...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.