Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
NetShareAdd (netapi32)
Adds a new network share to either a local or remote server

C# Signature:

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



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!

NetShareAdd on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Find References
Show Printable Version