Share of directory 
Author Message
 Share of directory

Hello,

I wish to create a sharing of a repertory in code VB (NT).
I think that it is with api NetshareAdd, how used in VB.

Thanks



Sun, 11 Aug 2002 03:00:00 GMT  
 Share of directory
Roy Strickland posted code in this newsgroup for this yesterday in response
to a similar question.  Search for the thread titled 'How can
programmatically share a drive?'
-Paul
--
Paul Little, Senior Programmer/Analyst
SVi Retail Systems
San Diego, CA


Quote:
> Hello,

> I wish to create a sharing of a repertory in code VB (NT).
> I think that it is with api NetshareAdd, how used in VB.

> Thanks



Sun, 11 Aug 2002 03:00:00 GMT  
 Share of directory

Quote:
> I wish to create a sharing of a repertory in code VB (NT).
> I think that it is with api NetshareAdd, how used in VB.

Option Explicit

Declare Function NetShareAdd Lib "netapi32.dll" (ByVal _
    servername As String, ByVal Level As Long, LPBYTE As Any, _
    lpParm_Err As Long) As Long

Type SHARE_INFO_2
    ShI2_NetName As String
    ShI2_Type As Long
    ShI2_Remark As String
    ShI2_Permissions As Long
    ShI2_Max_Uses As Long
    ShI2_Current_Uses As Long
    ShI2_Path As String
    ShI2_Passwd As String
End Type

Public Const STYPE_DISKTREE = 0
Public Const SHI_USES_UNLIMITED = -1&
Public Const ACCESS_READ = &H1

Public Function ShareAdd(ByVal sServerName As String, ByVal _
    sShareName As String, ByVal sPathName As String, Optional _
    ByVal sComment As Variant, Optional ByVal iMaxUses As Variant) _
    As Long

    Dim ShareInfo As SHARE_INFO_2, iParamError As Long
    If IsMissing(sComment) Then sComment = vbNullString

    If IsMissing(iMaxUses) Then iMaxUses = SHI_USES_UNLIMITED

    ShareInfo.ShI2_NetName = StrConv(sShareName, vbUnicode)
    ShareInfo.ShI2_Type = STYPE_DISKTREE
    ShareInfo.ShI2_Remark = StrConv(sComment, vbUnicode)

    ShareInfo.ShI2_Permissions = ACCESS_READ
    ShareInfo.ShI2_Max_Uses = iMaxUses
    ShareInfo.ShI2_Current_Uses = 0
    ShareInfo.ShI2_Path = StrConv(sPathName, vbUnicode)

    ShareInfo.ShI2_Passwd = StrConv(vbNullString, vbUnicode)
    ShareAdd = NetShareAdd(StrConv(sServerName, vbUnicode), _
       2, ShareInfo, iParamError)
End Function



Mon, 12 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Sharing a directory using vb

2. Sharing a directory

3. Detect Shared Drives/Directories

4. Share a directory with VB

5. Sharing a directory

6. Sharing a directory from within VB

7. Sharing a directory

8. Share a directory with VB

9. ++Sharing a directory

10. Sharing a directory

11. Share a directory with VB

12. Sharing local directories

 

 
Powered by phpBB® Forum Software