| Main | Site Index | Download | Disclaimer | Privacy |


 

 

 

 

WINDOWS SHARE: STRUCT AND FUNCTIONS

 

 

 

 

This supplementary note provides information for other functions and structures used in program examples of the Windows Share tutorials.  The information compiled for NT 5 (Windows 2000 and above).

 

The Page Index:

Structure:

  1. SHARE_INFO_2

  2. SHARE_INFO_1004

  3. SHARE_INFO_502

Function:

  1. IsValidSecurityDescriptor()

  2. NetApiBufferFree()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SHARE_INFO_2

 

Item

Description

Structure

SHARE_INFO_2.

Info

Contains information about the shared resource, including name of the resource, type and permissions, and the number of current connections.

Definition

typedef struct _SHARE_INFO_2 {

  LPWSTR shi2_netname;

  DWORD shi2_type;

  LPWSTR shi2_remark;

  DWORD shi2_permissions;

  DWORD shi2_max_uses;

  DWORD shi2_current_uses;

  LPWSTR shi2_path;

  LPWSTR shi2_passwd;

} SHARE_INFO_2, *PSHARE_INFO_2, *LPSHARE_INFO_2;

Members

See below.

Header file

<lm.h>

Remark

-

 

Table 1.

 

Members

 

shi2_netname - Pointer to a Unicode string specifying the share name of a resource.  Calls to the NetShareSetInfo() function ignore this member.

shi2_type - Specifies a DWORD value that contains the type of the shared resource.  Calls to the NetShareSetInfo() function ignore this member.

 

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.

STYPE_TEMPORARY

A temporary share.

 

Table 2.

 

shi2_remark - Pointer to a Unicode string that contains an optional comment about the shared resource.

shi2_permissions - Specifies a DWORD value that indicates the shared resource's permissions for servers running with share-level security.  A server running user-level security ignores this member.  This member can be one or more of the following values.  Calls to the NetShareSetInfo() function ignore this member. Note that the Windows Server 2003 family, Windows XP, Windows 2000, and Windows NT do not support share-level security.

 

Value

Meaning

ACCESS_READ

Permission to read data from a resource and, by default, to execute the resource.

ACCESS_WRITE

Permission to write data to the resource.

ACCESS_CREATE

Permission to create an instance of the resource (such as a file); data can be written to the resource as the resource is created.

ACCESS_EXEC

Permission to execute the resource.

ACCESS_DELETE

Permission to delete the resource.

ACCESS_ATRIB

Permission to modify the resource's attributes (such as the date and time when a file was last modified).

ACCESS_PERM

Permission to modify the permissions (read, write, create, execute, and delete) assigned to a resource for a user or application.

ACCESS_ALL

Permission to read, write, create, execute, and delete resources, and to modify their attributes and permissions.

 

Table 3.

 

shi2_max_uses - Specifies a DWORD value that indicates the maximum number of concurrent connections that the shared resource can accommodate.  The number of connections is unlimited if the value specified in shi2_max_uses is –1.

shi2_current_uses - Specifies a DWORD value that indicates the number of current connections to the resource.  Calls to the NetShareSetInfo() function ignore this member.

shi2_path - Pointer to a Unicode string specifying the local path for the shared resource.  For disks, shi2_path is the path being shared.  For print queues, shi2_path is the name of the print queue being shared.  Calls to the NetShareSetInfo() function ignore this member.

shi2_passwd - Pointer to a Unicode string that specifies the share's password when the server is running with share-level security.  If the server is running with user-level security, shi2_passwd is ignored.  The shi2_passwd member can be no longer than SHPWLEN+1 bytes (including a terminating null character).  Calls to the NetShareSetInfo() function ignore this member.  Note that the Windows Server 2003 family, Windows XP, Windows 2000, and Windows NT do not support share-level security.

 

SHARE_INFO_1004

 

Item

Description

Structure

SHARE_INFO_1004.

Info

Contain a comment associated with the shared resource.

Definition

typedef struct _SHARE_INFO_1004 {

  LPWSTR shi1004_remark;

} SHARE_INFO_1004, *PSHARE_INFO_1004, *LPSHARE_INFO_1004;

Members

shi1004_remark

Pointer to a Unicode string that contains an optional comment about the shared resource.

Header file

<lm.h>

Remark

-

 

Table 4.

 

SHARE_INFO_502

 

Item

Description

Structure

SHARE_INFO_502.

Info

Contains information about the shared resource, including name of the resource, type and permissions, number of connections, and other pertinent information.

Definition

typedef struct _SHARE_INFO_502 {

  LPWSTR shi502_netname;

  DWORD shi502_type;

  LPWSTR shi502_remark;

  DWORD shi502_permissions;

  DWORD shi502_max_uses;

  DWORD shi502_current_uses;

  LPWSTR shi502_path;

  LPWSTR shi502_passwd;

  DWORD shi502_reserved;

  PSECURITY_DESCRIPTOR shi502_security_descriptor;

} SHARE_INFO_502, *PSHARE_INFO_502, *LPSHARE_INFO_502;

Members

See below.

Header file

<lm.h>

Remark

-

 

Table 5.

 

Members

 

shi502_netname - Pointer to a Unicode string specifying the name of a shared resource.  Calls to the NetShareSetInfo() function ignore this member.

shi502_type - Specifies a DWORD value that indicates the type of share.  Calls to the NetShareSetInfo() function ignore this member.

 

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.

STYPE_TEMPORARY

A temporary share.

 

 Table 6.

 

shi502_remark - Pointer to a Unicode string specifying an optional comment about the shared resource.

shi502_permissions - Specifies a DWORD value that indicates the shared resource's permissions for servers running with share-level security.  This member is ignored on a server running user-level security.  This member can be any of the following values.  Calls to the NetShareSetInfo() function ignore this member.  Note that the Windows Server 2003 family, Windows XP, Windows 2000, and Windows NT do not support share-level security.

 

Value

Meaning

ACCESS_READ

Permission to read data from a resource and, by default, to execute the resource.

ACCESS_WRITE

Permission to write data to the resource.

ACCESS_CREATE

Permission to create an instance of the resource (such as a file); data can be written to the resource as the resource is created.

ACCESS_EXEC

Permission to execute the resource.

ACCESS_DELETE

Permission to delete the resource.

ACCESS_ATRIB

Permission to modify the resource's attributes (such as the date and time when a file was last modified).

ACCESS_PERM

Permission to modify the permissions (read, write, create, execute, and delete) assigned to a resource for a user or application.

ACCESS_ALL

Permission to read, write, create, execute, and delete resources, and to modify their attributes and permissions.

 

Table 7.

 

shi502_max_uses - Specifies a DWORD value that indicates the maximum number of concurrent connections that the shared resource can accommodate.  The number of connections is unlimited if the value specified in shi502_max_uses is –1.

shi502_current_uses - Specifies a DWORD value that indicates the number of current connections to the resource.  Calls to the NetShareSetInfo() function ignore this member.

shi502_path - Pointer to a Unicode string that contains the local path for the shared resource.  For disks, shi502_path is the path being shared.  For print queues, shi502_path is the name of the print queue being shared.  Calls to the NetShareSetInfo() function ignore this member.

shi502_passwd - Pointer to a Unicode string that specifies the share's password (when the server is running with share-level security).  If the server is running with user-level security, shi502_passwd is ignored.  Note that the Windows Server 2003 family, Windows XP, Windows 2000, and Windows NT do not support share-level security. The shi502_passwd member can be no longer than SHPWLEN+1 bytes (including a terminating null character).  Calls to the NetShareSetInfo() function ignore this member.

shi502_reserved - Reserved; must be zero. Calls to the NetShareSetInfo() function ignore this member.

shi502_security_descriptor - Specifies the SECURITY_DESCRIPTOR associated with this share.

 

IsValidSecurityDescriptor()

 

Item

Description

Function

IsValidSecurityDescriptor().

Use

To determine whether the components of a security descriptor are valid.

Prototype

BOOL IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR pSecurityDescriptor);

Parameters

pSecurityDescriptor - [in] Pointer to a SECURITY_DESCRIPTOR structure that the function validates.

Return value

If the components of the security descriptor are valid, the return value is nonzero.  If any of the components of the security descriptor are not valid, the return value is zero.  There is no extended error information for this function; do not call GetLastError().

Include file

<windows.h>

Remark

The IsValidSecurityDescriptor() function checks the validity of the components that are present in the security descriptor.  It does not verify whether certain components are present.

 

Table 8.

 

NetApiBufferFree()

 

Item

Description

Function

NetApiBufferFree().

Use

To Free the memory that the NetApiBufferAllocate() function allocates.  Call NetApiBufferFree() to free the memory that other network management functions return.

Prototype

NET_API_STATUS NetApiBufferFree(LPVOID Buffer);

Parameters

Buffer - [in] Pointer to a buffer returned previously by another network management function.

Return value

If the function succeeds, the return value is NERR_Success.  If the function fails, the return value is a Windows system error code.

Include file

<lm.h>

Remark

No special group membership is required to successfully execute the ApiBuffer functions.

 

Table 9.

 

-----------------------------End Module Q-------------------------

 

 

 

 

 

 

 

 

 

 

 

 

Further reading and digging:

 

  1. Check the best selling C, C++ and Windows books at Amazon.com.

  2. Microsoft Visual C++, online MSDN.

  3. MSDN library.

  4. For Multibytes, Unicode characters and Localization stories please refer to Multibyte & Unicode 1 and Multibyte & Unicode 2.

  5. Structure, enum, union and typedef story can be found at enum, typedef, struct etc.

  6. Notation used in MSDN is Hungarian Notation instead of CamelCase and is discussed C & C++ Notation.

  7. Windows data type information is in Windows data types.

 

 

 

 

 

 

| Main | Site Index | Download | Disclaimer | Privacy |