Platform SDK: Network Management |
The NetShareCheck function checks whether or not a server is sharing a device.
No special group membership is required to successfully execute the NetShareCheck function.
NET_API_STATUS NetShareCheck( LPWSTR servername, LPWSTR device, LPDWORD type );
Value | Meaning |
---|---|
STYPE_DISKTREE | Disk drive |
STYPE_PRINTQ | Print queue |
STYPE_DEVICE | Communication device |
STYPE_IPC | Interprocess communication (IPC) |
STYPE_SPECIAL | Special share reserved for interprocess communication (IPC$) or remote administration of the server (ADMIN$). Can also refer to administrative shares such as C$, D$, E$, and so forth. For more information, see the network management share functions. |
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_NOT_ENOUGH_MEMORY | Insufficient memory is available. |
NERR_DeviceNotShared | The device is not shared. |
The following code sample demonstrates how to check whether a server is sharing a device, using a call to the NetShareCheck function. The function returns the type of device being shared, as described in the preceding documentation for the type parameter.
#define UNICODE #include <windows.h> #include <stdio.h> #include <lm.h> void wmain( int argc, TCHAR *argv[ ]) { NET_API_STATUS res; DWORD devType = 0; if(argc<3) printf("Usage: NetShareCheck server device\n"); else { // // Call the NetShareCheck function. // res=NetShareCheck(argv[1], _wcsupr(argv[2]), &devType); // // If the function succeeds, inform the user. // if(res==0) printf("Device is shared as type %u.\n",devType); // // Otherwise, print the error. // 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: Unsupported.
Header: Declared in Lmshare.h; include Lm.h.
Library: Use Netapi32.lib.
Network Management Overview, Network Management Functions, Share Functions, NetShareEnum, NetShareGetInfo