Click to See Complete Forum and Search --> : Sharing a Drive Through Code


waqas_hussain
July 3rd, 2001, 09:54 PM
how can i share a computer's drive through vb code.

cksiow
July 5th, 2001, 01:16 AM
the following code might help (for win98)



Global Const LM20_NNLEN as Long = 12 + 1
Global Const SHPWLEN as Long = 9
Global Const SHI50F_RDONLY = &H1&
Global Const SHI50F_FULL = &H2&
Global Const SHI50F_PERSIST = &H100&
Global Const STYPE_DISKTREE = 0


public Type share_info_50
shi50_netname as string * LM20_NNLEN
shi50_type as Byte
shi50_flags as Integer
shi50_remark as string
shi50_path as string
shi50_rw_password as string * SHPWLEN
shi50_ro_password as string * SHPWLEN
End Type

Declare Function NetShareAdd98 Lib "svrapi.dll" Alias "NetShareAdd" (byval pszServer as string, byval slevel as Long, pbBuffer as Any, byval cbBuffer as Long) as Long

public Function ShareDrive(byval NetName as string, byval Path as string, optional byval Remark as string = vbNullString, optional byval ReadPassword as string = vbNullString, optional byval RWPassword as string = vbNullString) as Long
Dim lpBuffer as share_info_50

With lpBuffer
.shi50_netname = NetName & Chr$(0)
.shi50_type = STYPE_DISKTREE
.shi50_flags = SHI50F_FULL
.shi50_remark = Remark & Chr$(0)
.shi50_path = UCase(Path)
.shi50_rw_password = RWPassword & Chr$(0)
.shi50_ro_password = ReadPassword & Chr$(0)
End With

Debug.print NetShareAdd98(vbNullString, 50, lpBuffer, len(lpBuffer))

End Function





HTH

cksiow
http://vblib.virtualave.net - share our codes