欢迎光临
我们一直在努力

目录共享-.NET教程,数据库应用

建站超值云服务器,限时71元/月

option explicit

netshareadd在win9x下是放在srvapi.dll中,而在nt下则入在netapi32.dll中。

在win98下应使用结构share_info_50

在nt下应使用结构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 权限

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

为指定的计算机添加共享

server 为计算机名

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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 目录共享-.NET教程,数据库应用
分享到: 更多 (0)

相关推荐

  • 暂无文章