Skip to content

Latest commit

 

History

History
258 lines (205 loc) · 6.1 KB

nf-lmshare-netsharecheck.md

File metadata and controls

258 lines (205 loc) · 6.1 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:lmshare.NetShareCheck
NetShareCheck function (lmshare.h)
Checks whether or not a server is sharing a device.
NetShareCheck
NetShareCheck function [Files]
STYPE_DEVICE
STYPE_DISKTREE
STYPE_IPC
STYPE_PRINTQ
STYPE_SPECIAL
STYPE_TEMPORARY
_win32_netsharecheck
fs.netsharecheck
lmshare/NetShareCheck
netmgmt.netsharecheck
fs\netsharecheck.htm
fs
8453dcd2-5c58-4fe4-9426-0fd51647394d
12/05/2018
NetShareCheck, NetShareCheck function [Files], STYPE_DEVICE, STYPE_DISKTREE, STYPE_IPC, STYPE_PRINTQ, STYPE_SPECIAL, STYPE_TEMPORARY, _win32_netsharecheck, fs.netsharecheck, lmshare/NetShareCheck, netmgmt.netsharecheck
lmshare.h
Lm.h
Windows
Windows XP [desktop apps only]
Windows Server 2003 [desktop apps only]
Netapi32.lib
Netapi32.dll
Windows
19H1
NetShareCheck
lmshare/NetShareCheck
c++
APIRef
kbSyntax
DllExport
Netapi32.dll
NetShareCheck

NetShareCheck function

-description

Checks whether or not a server is sharing a device.

-parameters

-param servername [in]

Pointer to a 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.

-param device [in]

Pointer to a string that specifies the name of the device to check for shared access.

-param type [out]

Pointer to a variable that receives a bitmask of flags that specify the type of the shared device. This parameter is set only if the function returns successfully.

One of the following flags may be specified.

Value Meaning
STYPE_DISKTREE
Disk drive.
STYPE_PRINTQ
Print queue.
STYPE_DEVICE
Communication device.
STYPE_IPC
Interprocess communication (IPC).
 

In addition, one or both of the following flags may be specified.

Value Meaning
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 Network Share Functions.
STYPE_TEMPORARY
A temporary share.

-returns

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.

Return code Description
ERROR_NOT_ENOUGH_MEMORY
Insufficient memory is available.
NERR_DeviceNotShared
The device is not shared.

-remarks

This function applies only to Server Message Block (SMB) shares. For other types of shares, such as Distributed File System (DFS) or WebDAV shares, use Windows Networking (WNet) functions, which support all types of shares.

No special group membership is required to successfully execute the NetShareCheck function.

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.

Examples

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.

#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#include <stdio.h>
#include <lm.h>
#pragma comment(lib, "Netapi32.lib")

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], 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;
}

-see-also

NetShareEnum

NetShareGetInfo

Network Management Functions

Network Management Overview

Network Share Functions