NetShareAdd (netapi32)
Last changed: -188.209.80.210

.
Summary
Adds a new network share to either a local or remote server

C# Signaturea:

[DllImport("netapi32.dll", SetLastError=true)]
static extern TODO NetShareAdd(TODO);

VB Signature:

Declare Unicode Function NetShareAdd Lib "netapi32.dll" _
            (ByVal servername As String, _
            ByVal level As Integer, _
            ByRef buf As SHARE_INFO_2, _
            ByRef parm_err As Integer) As Integer

User-Defined Types:

None.

Notes:

[2004-06-11]
VB Def and Sample code added by RACKLEY

Tips & Tricks:

Please add some!

Sample Code:

Dim shi2 As SHARE_INFO_2

' Populate the structure with information
shi2.shi2_netname = sharename"      ' share name
shi2.shi2_type = STYPE_DISKTREE     ' disk drive
shi2.shi2_remark = ""           ' share comment
shi2.shi2_permissions = 0
shi2.shi2_max_uses = -1        ' unlimited    
shi2.shi2_current_uses = 0
shi2.shi2_path = "c:\myshare"
shi2.shi2_passwd = Nothing      ' no password

retval = NetShareAdd(ServerName, 2, shi2, Nothing)

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
NetShareAdd on MSDN