Share Functions

The 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:

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.

The WNetEnumResource function should be used instead of the NetShareEnum function, which is obsolete.

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 may also specify a Security Descriptor to be associated with a share, which specifies which users will be allowed to access files through this share, and with what type of access.

LAN Manager defines three types of 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.

Share functions are available at four information levels:

SHARE_INFO_0
SHARE_INFO_1
SHARE_INFO_2
SHARE_INFO_502

The following information levels are valid only for NetShareSetInfo:

SHARE_INFO_1004
SHARE_INFO_1006

The following is supported only on Windows NT:

SHARE_INFO_1501

For NetShareSetInfo, parmnum values refer to the members of the SHARE_INFO structure, as follows. These values are used when indicating an error in a specific parameter through parm_err.

parmnum value Member of SHARE_INFO structure
SHARE_NETNAME_PARMNUM shi_netname
SHARE_TYPE_PARMNUM shi_type
SHARE_REMARK_PARMNUM shi_remark
SHARE_PERMISSIONS_PARMNUM shi_permissions
SHARE_MAX_USES_PARMNUM shi_max_uses
SHARE_CURRENT_USES_PARMNUM shi_current_uses
SHARE_PATH_PARMNUM shi_path
SHARE_PASSWD_PARMNUM shi_passwd
SHARE_FILE_SD_PARMNUM shi_security_descriptor