Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Share a folder in VB

Posted on 1998-05-20
3
Medium Priority
?
789 Views
Last Modified: 2008-02-01
How can I programmatically share a folder, including rights and password, from VB?
0
Comment
Question by:ianders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:woka
ID: 1456378
This question is for Yowkee to get his points.  Please don't submit an answer unless that's you.
0
 
LVL 4

Accepted Solution

by:
yowkee earned 400 total points
ID: 1456379
Thanks woka. :)
I post the code once again.

'=====General Declaration======
Private Type Share_Info_50
    shi50_netname As String * 13
    shi50_type As Byte
    shi50_flags As Integer
    shi50_remark As String
    shi50_path As String
    shi50_rw_pssword As String * 9
    shi50_ro_password As String * 9
End Type

Public Const SHI50F_RDONLY = &H1
Public Const SHI50F_FULL = &H2
Public Const SHI50F_DEPENDSON = SHI50F_RDONLY Or SHI50F_FULL
Public Const SHI50F_ACCESSMASK = SHI50F_RDONLY Or SHI50F_FULL
Public Const SHI50F_PERSIST = &H100
Public Const SHI50F_SYSTEM = &H200
Public Const STYPE_DISKTREE = 0
Public Const SHI_USES_UNLIMITED = 31

Private Declare Function NetShareAdd Lib "Svrapi.dll" _
    (ByVal Server As String, _
     ByVal Level As Long, _
     si As Share_Info_50, _
     ByVal Length As Long) As Long

'======Function to share directory========
Public Function Share(ByVal lpShareName As String, _
                      ByVal lpPath As String, _
                      ByVal lpRemark As String, _
                      ByVal lpPassword As String) As Long
                                   
   Dim lRtn As Long
   Dim lLen as Long
   Dim si50 As Share_Info_50
   
   si50.shi50_netname = lpShareName + vbNullChar
   si50.shi50_type = STYPE_DISKTREE
   si50.shi50_remark = lpRemark + vbNullChar
   si50.shi50_path = UCase(lpPath) + vbNullChar
   si50.shi50_ro_password = lpPassword + vbNullChar
   si50.shi50_rw_pssword = lpPassword + vbNullChar
   si50.shi50_flags = SHI50F_PERSIST Or SHI50F_FULL
   
   lLen = Len(si50)
   
   lRtn = NetShareAdd(vbNullString, 50, si50, lLen)
   if lRtn <> 0 then debug.print "Failed to share folder"
End Function

Hope this help.
 

0
 

Author Comment

by:ianders
ID: 1456380
You 'da man.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question