The functions in the Share category control shared resources.
|
Function |
Description |
|
Shares a resource on a server. |
|
|
This function is the same as NetShareAdd except that it uses 32-bit data structures, is RPC-based, and supports additional information levels. |
|
|
Queries whether a server is sharing a device. |
|
|
This function is the same as NetShareCheck except that it is RPC-based. |
|
|
Deletes a share name from a servers list of shared resources. |
|
|
This function is the same as NetShareDel except that it is RPC-based. |
|
|
Retrieves share information about each shared resource on a server. |
|
|
This function is the same as NetShareEnum except that it uses 32-bit data structures, is RPC-based, supports additional information levels, and is resumable. |
|
|
Retrieves information about a specified shared resource on a server. |
|
|
This function is the same as NetShareGetInfo except that it uses 32-bit data structures, is RPC-based, and supports additional information levels. |
|
|
Sets a shared resources parameters. |
|
|
This function is the same as NetShareSetInfo except that it uses 32-bit data structures, is RPC-based, and supports additional information levels. |
A shared resource refers to a servers local resource (for example, a disk drive, print device, or named pipe) that other applications on the network can access. A unique share name is assigned to each shared resource to enable remote users and applications to refer to the shared resource, rather than the shares local device name.
When allowing remote users and applications to access a server resource, you must first share the resource by assigning it a share name. NetShareAdd and NetShareAdd32 add a share to a server.
NetShareAdd and NetShareAdd32 require only a share name and a local device name to share a resource. A user or application must have an account on the server to access the resource.
For information on setting up user accounts on servers, see User Category. For information on assigning permissions in, see Access Permissions Category.
In addition to providing for the sharing of normal resources, Advanced Server defines special shares necessary for interprocess communications (IPC) and remote administration of the server. The types of special shares are defined as follows:
The IPC$ resource is reserved for IPC.
The ADMIN$ resource is reserved for remote administration.
C$ shares the local disk device for remote administration.
Share information can be returned by the NetShareEnum and NetShareGetInfo functions at one of three levels of detail (0, 1, and 2) specified by the sLevel parameter. NetShareAdd requires level 2 detail. NetShareSetInfo can be called with level 1 or 2.
Share information can be retrieved by NetShareEnum32 and NetShareGetInfo32 at levels 0, 1, 2, and 502.
NetShareAdd32 requires levels 2 or 502.
NetShareSetInfo32 can be called with levels 1, 2, 502, 1004, 1006, and 1501.
The share_info_0 data structure that can be returned by NetShareEnum or NetShareGetInfo has the following format:
struct share_info_0 {
char shi0_netname[LM20_NNLEN+1];
};
Within this structure, shi0_netname is an ASCIIZ string containing the share name of a resource.
The SHARE_INFO_0 data structure that can be used by NetShareEnum32 or NetShareGetInfo32 has the following format:
typedef struct _SHARE_INFO_0 {
LPTSTR shi0_netname;
} SHARE_INFO_0, *PSHARE_INFO_0, *LPSHARE_INFO_0;
Within this structure, all parameters are defined in the same way as in the share_info_0 data structure.
The share_info_1 data structure that can be used by NetShareEnum, NetShareGetInfo, or NetShareSetInfo has the following format:
struct share_info_1 {
char shi1_netname[LM20_NNLEN+1];
char shi1_pad1;
unsigned short shi1_type;
char * shi1_remark;
};
Within this structure, the following parameters are defined:
shi1_netname is an ASCIIZ string containing the share name of a resource. NNLEN is defined in the netcons.h header file.
shi1_pad1 word-aligns the data structure components.
shi1_type is one of four values specifying the type of share, as defined in the shares.h file as follows:
|
Manifest |
Value |
Meaning |
|
STYPE_DISKTREE |
0 |
Disk drive |
|
STYPE_PRINTQ |
1 |
Print queue |
|
STYPE_DEVICE |
2 |
Character device |
|
STYPE_IPC |
3 |
Interprocess communications (IPC) |
shi1_remark points to an ASCIIZ string containing an optional comment about the shared resource.
The SHARE_INFO_1 data structure that can be used by NetShareEnum32, NetShareGetInfo32, or NetShareSetInfo32 has the following format:
typedef struct _SHARE_INFO_1 {
LPTSTR shi1_netname;
DWORD shi1_type;
LPTSTR shi1_remark;
} SHARE_INFO_1, *PSHARE_INFO_1, *LPSHARE_INFO_1;
Within this structure, all parameters are defined in the same way as in share_info_1 data structure.
The share_info_2 data structure that can be used by NetShareEnum, NetShareGetInfo, NetShareSetInfo, or NetShareAdd has the following format:
struct share_info_2 {
char shi2_netname[LM20_NNLEN+1];
char shi2_pad1;
unsigned short shi2_type;
char * shi2_remark;
unsigned short shi2_permissions
unsigned short shi2_max_uses;
unsigned short shi2_current_uses;
char * shi2_path;
char shi2_pad2;
};
Within this structure, the following parameters are defined:
shi2_netname through shi2_remark are the same as the corresponding elements of the share_info_1 data structure. For a complete description, see Share Information (level 1).
shi2_max_uses gives the maximum number of concurrent connections that the shared resource can accommodate (unlimited if the shi2_max_uses value is -1).
shi2_current_uses specifies how many connections are currently made to the resource.
shi2_path points to an ASCIIZ string containing the shared resources local path name. For disks, shi2_path is the path being shared. For print queues, shi2_path is the name of the print queue being shared.
shi2_pad2 word-aligns the data structure components.
The SHARE_INFO_2 data structure that can be used by NetShareEnum32, NetShareGetInfo32, NetShareAdd32, or NetShareSetInfo32 has the following format:
typedef struct _SHARE_INFO_2 {
LPTSTR shi2_netname;
DWORD shi2_type;
LPWSTR shi2_remark;
DWORD shi2_permissions;
DWORD shi2_max_uses;
DWORD shi2_current_uses;
LPTSTR shi2_path;
LPTSTR shi2_passwd;
} SHARE_INFO_2, *PSHARE_INFO_2, *LPSHARE_INFO_2;
Within this structure, all parameters are defined in the same way as in share_info_2 data structure.
The SHARE_INFO_502 data structure that can be used by NetShareEnum32, NetShareGetInfo32, NetShareAdd32, or NetShareSetInfo32 has the following format:
typedef struct _SHARE_INFO_502 {
LPTSTR shi502_netname;
DWORD shi502_type;
LPTSTR shi502_remark;
DWORD shi502_permissions;
DWORD shi502_max_uses;
DWORD shi502_current_uses;
LPTSTR shi502_path;
LPTSTR shi502_passwd;
DWORD shi502_reserved;
PSECURITY_DESCRIPTOR shi502_security_descriptor;
} SHARE_INFO_502, *PSHARE_INFO_502, *LPSHARE_INFO_502;
Within this structure, the following parameters are defined:
shi502_netname through shi502_password are the same as the corresponding elements in the SHARE_INFO_2 data structure.
shi502_security_descriptor specifies the security descriptor for this shared resource.
The following info levels are only valid for NetShareSetInfo32 and replace the older way of passing in a Parmnum to set a specific field.
The following information structures also are supported on down-level systems such as LAN Manager 2.x .
The SHARE_INFO_1004 data structure has the following format:
typedef struct _SHARE_INFO_1004 {
LPTSTR shi1004_remark;
} SHARE_INFO_1004, *PSHARE_INFO_1004, *LPSHARE_INFO_1004;
Within this structure, shi1004_remark points to an ASCIIZ string containing an optional comment about the shared resource.
The SHARE_INFO_1006 data structure has the following format:
typedef struct _SHARE_INFO_1006 {
DWORD shi1006_max_uses;
} SHARE_INFO_1006, *PSHARE_INFO_1006, *LPSHARE_INFO_1006;
Within this structure, shi1006_max_uses specifies the maximum number of concurrent connections that the shared resource can accommodate.
The following information structure is supported only on Windows NT.
The SHARE_INFO_1501 data structure has the following format:
typedef struct _SHARE_INFO_1501 {
DWORD shi1501_reserved;
PSECURITY_DESCRIPTOR shi1501_security_descriptor;
} SHARE_INFO_1501, *PSHARE_INFO_1501, *LPSHARE_INFO_1501;
Within this structure, shi1501_security_descriptor specifies the security descriptor for this shared resource.
For NetShareSetInfo32, parmnum values refer to the fields in the SHARE_INFO structure as follows. These values are used when indicating an error in a specific parameter using parm_err.
|
parmnum value |
Field in share_info struct |
|
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 |