Platform SDK: Network Management |
The NetShareDel function deletes a share name from a server's list of shared resources, disconnecting all connections to the shared resource.
Only members of the Administrators or Account Operators local group or those with Communication, Print, or Server operator group membership can successfully execute the NetShareDel function. The Print operator can delete only Printer queues. The Communication operator can delete only communication-device queues.
Windows NT/2000: The parameter order is as follows.
NET_API_STATUS NetShareDel( LPWSTR servername, LPWSTR netname, DWORD reserved );
Windows 95/98: Following is the function prototype on Windows 95/98.
extern API_FUNCTION NetShareDel( const char FAR * pszServer, const char FAR * pszNetName, unsigned short usReserved );
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes.
Value | Meaning |
---|---|
ERROR_ACCESS_DENIED | The user does not have access to the requested information. |
ERROR_INVALID_PARAMETER | The specified parameter is invalid. |
ERROR_NOT_ENOUGH_MEMORY | Insufficient memory is available. |
NERR_NetNameNotFound | The share name does not exist. |
Windows 95/98: See the NetShareDel Sample (Windows 95/98) topic to view a code sample that demonstrates how to use the NetShareDel function.
Windows NT/2000: The following code sample demonstrates how to delete a share using a call to the NetShareDel function.
#define UNICODE #include <windows.h> #include <stdio.h> #include <lm.h> void wmain( int argc, TCHAR *argv[ ]) { NET_API_STATUS res; if(argc<3) printf("Usage: NetShareDel server share\n"); else { // // Call the NetShareDel function to delete the share. // res=NetShareDel(argv[1], argv[2], 0); // // Display the result of the call. // if(res==0) printf("Share Removed.\n"); else printf("Error: %u\n", res); } return; }
If you are programming for Active Directory, you may be able to call certain Active Directory Service Interface (ADSI) methods to achieve the same functionality you can achieve by calling the network management share functions. For more information, see IADsFileShare.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Lmshare.h (Windows NT/2000) or Svrapi.h (Windows 95/98); include Lm.h (Windows NT/2000).
Library: Use Netapi32.lib (Windows NT/2000) or Svrapi.lib (Windows 95/98).
Network Management Overview, Network Management Functions, Share Functions, NetShareAdd