HELP NetShareAdd function
I'm trying to share directories by software. (
Visual Basic). I'm looking
for an example of use of the NetShareAdd function under Visual Basic
5.0. I know the C declaration of this function but I have some problems
to translate it in Visual Basic.
here is the C declaration:
********************** BEGINING OF DOCUMENTATION ***********************
NET_API_STATUS NetShareAdd(
LPTSTR servername,
DWORD level,LPBYTE buf,
LPDWORD parm_err
);
Parameters :
servername
Pointer to a Unicode string containing the name of the remote server on
which the function is to execute. A NULL poiunter or string specifies
the local computer.
level
Specifies one of the following values to set the level of information
provided.
Value meaning :
2 The buf parameter points to an array of SHARE_INFO_2 structures
502 The buf parameter points to an array of SHARE_INFO_502 structures
buf
Pointer to the buffer in which the data set with the level parameter is
stored.
parm_err
Optional pointer to a DWORD that contains the index of the first
parameter that causes ERROR_INVALID_PARAMETER. If NULL, the parameter is
not returned on error.
RETURN VALUES:
If successfull, the return value is NERR_Success (0)
If the function fails :
ERROR_ACCESS_DENIED (5)
ERROR_INVALID_LEVEL (&H124)
ERROR_INVALID_NAME (&H123)
ERROR_INVALID_PARAMETER (87)
NERR_Duplicate_Share (2118)
NERR_Redirected_Path (2117)
NOTES ON DECLARATION OF SHARE_INFO_2 STRUCTURE :
typedef struct _SHARE_INFO_2 {
LPTSTR shi2_netname;
DWORD shi2_type;
LPTSTR 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;
Members
shi2_name :
A unicode string containing the sharename of the ressource.
shi2_type :
This member can be one of the following types:
STYPE_DISKTREE Disk drive
STYPE_PRINTQ Print queue
STYPE_DEVICE Communication device
STYPE_IPC Introprocess communication
shi2_remark:
String of remark
shi2_permissions
Value needed (for me) ACCESS_ALL (I think that the value is &HB700)
shi2_max_uses
maximum number of concurrent connections (unlimited if = -1)
shi2_current_uses
Number of current connections to the resource
shi2_path
points to a Unicode string containing the local path for the shared
resource.
shi2_passwd :
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)
********************** END OF DOCUMENTATION ***********************