The network management share functions control shared resources. A shared resource is a local resource on a server (for example, a disk directory, print device, or named pipe) that can be accessed by users and applications on the network.
The share functions are listed following.
|NetShareAdd||Shares a resource on a server.|
|NetShareCheck||Queries whether a server is sharing a device.|
|NetShareDel||Deletes a share name from a server's list of shared resources.|
|NetShareEnum||Retrieves share information about each shared resource on a server.|
|NetShareGetInfo||Retrieves information about a specified shared resource on a server.|
|NetShareSetInfo||Sets a shared resource's parameters.|
These share function apply only to shares on a Server Message Block (LAN Manager) server. These share functions do not support Distributed File System (DFS) shares. For example, the NetShareGetInfo function can only retrieve information for a specified share resource on an SMB Server. To retrieve information for a share using a different network provider (WebDAV or a DFS share, for example), use the WNetGetConnection function.
The NetShareAdd function allows a user or application to share a resource of a specific type using the specified share name. The NetShareAdd function requires the share name and local device name to share the resource. A user or application must have an account on the server to access the resource.
You can also specify a security descriptor to be associated with a share. Security descriptors specify which users are allowed to access files through the share, and with what type of access. Specify a SECURITY_DESCRIPTOR with the SHARE_INFO_502 information level when calling NetShareAdd or NetShareSetInfo. NetShareSetInfo supports the SHARE_INFO_1501 information level. For more information about security descriptors, see Access Control.
The network management functions use the following special share names for interprocess communication (IPC) and remote administration of the server:
- IPC$, reserved for interprocess communication
- ADMIN$, reserved for remote administration
- A$, B$, C$ (and other local disk names followed by a dollar sign), assigned to local disk devices
To list all connections made to a shared resource on a server, or to list all connections established from a particular computer, call the NetConnectionEnum function. You can call NetConnectionEnum at the CONNECTION_INFO_0 and CONNECTION_INFO_1 information levels.
Share functions are available at the following information levels although some share levels are only applicable to some of the share functions:
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.