目錄共享
2024-07-21 02:23:16
供稿:網(wǎng)友
網(wǎng)站運(yùn)營(yíng)seo文章大全提供全面的站長(zhǎng)運(yùn)營(yíng)經(jīng)驗(yàn)及seo技術(shù)!option explicit
'netshareadd在win9x下是放在srvapi.dll中,而在nt下則入在netapi32.dll中。
'
'在win98下應(yīng)使用結(jié)構(gòu)share_info_50
'在nt下應(yīng)使用結(jié)構(gòu)share_info_2 和share_info_502
private declare function netshareadd lib "srvapi.dll" (byval servername as long, byval level as long, buf as any, parmerr as long) as long
private type share_info_2
shi2_netname as long '共享名
shi2_type as long '類型
shi2_remark as long '備注
shi2_permissions as long '權(quán)限
shi2_max_uses as long '最大用戶
shi2_current_uses as long '
shi2_path as long '路徑
shi2_passwd as long '密碼
end type
const stype_all = -1
const stype_disktree = 0
const stype_printq = 1
const stype_device = 2
const stype_ipc = 3
const stype_special = &h80000000
const access_read = &h1
const access_write = &h2
const access_create = &h4
const access_exec = &h8
const access_delete = &h10
const access_atrib = &h20
const access_perm = &h40
const access_all = access_read or access_write or access_create or access_exec or access_delete or access_atrib or access_perm
'為指定的計(jì)算機(jī)添加共享
'server 為計(jì)算機(jī)名
'sharepath 為共享路徑
'sharename 為共享名
'shareremark 為備注
'sharepw 為密碼
function addshare(server as string, sharepath as string, sharename as string, shareremark as string, sharepw as string) as boolean
dim lngserver as long
dim lngnetname as long
dim lngpath as long
dim lngremark as long
dim lngpw as long
dim parmerr as long
dim si2 as share_info_2
lngserver = strptr(server)
lngnetname = strptr(sharename)
lngpath = strptr(sharepath)
if len(shareremark) > 0 then
lngremark = strptr(shareremark)
end if
if len(sharepw) > 0 then
lngpw = strptr(sharepw)
end if
with si2
.shi2_netname = lngnetname
.shi2_path = lngpath
.shi2_remark = lngremark
.shi2_type = stype_disktree
.shi2_permissions = access_all
.shi2_max_uses = -1
.shi2_passwd = lngpw
end with
if netshareadd(lngserver, 2, si2, parmerr) = 0 then
addshare = true
else
addshare = false
end if
end function
private sub command1_click()
' mkdir "d:/123"
addshare "server", "d:/123", "123", "例子", ""
end sub