Sharing and deletion of folders under 98me

zhaozj2021-02-16  51

Independently input module Option Explicit 'share error message Public Const NERR_NoWorkstation = 2102' workstation driver is not installed .Public Const NERR_UnknownServer = 2103 'machine name unavailable .Public Const NERR_RemoteOnly = 2106' the machine operator is not supported .Public Const NERR_ServerNotStarted = 2114 'service is not started .Public Const NERR_UnknownDevDir = 2116' directory or drive does not exist .Public Const NERR_RedirectedPath = 2117 'of the shared resources can not be shared .Public Const NERR_DuplicateShare = 2118' the share name is already in use .Public Const NERR_NetworkError = 2136 'A general network error, sharing failed .Public const Nerr_INValidApi = 2142' The API is not supported by the remote machine.

'Standard Error Information Public Const Error_Access_Denied = 5public const Error_INVALID_PARER = 87public const error_INVALID_NAME = 123public const error_INVALID_LEVEL = 124

Public Declare Sub CopyMemory LIB "kernel32" Alias ​​"RTLMoveMemory" (LPDest As Any, LPSource As Any, BYVAL LBYTES AS as Long)

'Shared type public const stype_disktree = 0public const stype_printq = 1PUBLIC const stype_ipe = 3public const stype_special = & h80000000

Public const shi_uses_unlimited = -1 &

'Share permissions Public Const SHI50F_RDONLY = & H1Public Const SHI50F_FULL = & H2Public Const SHI50F_DEPENDSON = SHI50F_RDONLY Or SHI50F_FULLPublic Const SHI50F_ACCESSMASK = SHI50F_RDONLY Or SHI50F_FULLPublic Const SHI50F_PERSIST = & H100Public Const SHI50F_SYSTEM = & H200' / * this share is invisible * / Public Const LM20_NNLEN = 12 '/ / Lm 2.0 machine name length public const lm20_unlen = 20 '// LM 2.0 User Name Maximum length public const lm20_pwlen = 14' // LM 2.0 password Maximum length public const shpwlen = 8 '// Shared password (Bytes) public const sharelevel50 = 50PUBLIC TYPE SHARE_INFO_50 YNETNAME (LM20_NNLEN) AS BYTE 'Charshi50_NetName [LM20_NNLEN 1];' / * Shared Name * / YTYPE AS BYTE 'UNSIGNED CHAR Shi 50_TYPE

NFLAGS AS INTEGER 'Short Shi50_flags;

LPZREMARK AS Long 'Char Far * Shi50_Remark;

LPZPATH AS Long 'Char Far * Shi50_path;' / * Shared Path * / YRWPassword (SHPWLEN) AS BYTE 'CHAR SHI50_RW_PASSWORD [SHPWLEN 1];' / * Readable / Write Shared Password * / Yropassword (Shpwlen) AS BYTE 'CHAR Shi50_ro_password [Shpwlen 1]; '/ * Read-only Shared Password * / End Type

Public Declare Function NetShareadd50 lib "svrapi" alias "netshareadd" _ (byval lpzservername as string, _ byval nsharelevel as integer, _ shareinfo as any, _ byval nbuffearsize as integer) AS Long

Public Declare Function NetSharedlete Lib "Svrapi" Alias ​​"Netsharedel" _ (Byval LPZSERVERNAME AS STRING, _ BYVAL SSHARENAME AS STRING, _ BYVAL NRESERVED AS INTEGER AS Long '************ Establish Share * ****************** PUBLIC FUNCTION CREATESHARE (BYVAL SSHARENAME AS STRING, _ BYVAL SREMARK AS STRING, _ BYVAL SROPASS AS STRING, _ BYVAL SRWPASS AS String) AS Longdim ShareInfo As Share_INFO_50 DIM LRETURN AS LONG

DIM SSERVERNAME AS STRING DIM Ysharepath () AS BYTE DIM YREMARK () AS BYTE

sServerName = "" "Establish a local share

With shareinfo

.ytepe = stype_disktree 'disk type share .nflags = shi50f_persist shi50f_dependson' shi50f_system '

Ysharepath () = strconv (ucase $ (ssharepath & vbnullchar), vbfromunicode) .lpzpath = varptr (YsharePath (0))

YREMARK () = strconv (Sremark & ​​Vbnullchar, Vbfromunicode) .lpzremark = varptr (YREMARK (0))

Erase .ynetName () ssharename = ucase $ (ssharename & vbnullchar) CopyMemory .ynetName (0), byval ssharename, len (ssharename)

Erase .yrwpassword () SRWPASS = UCase $ (Srwpass & Vbnullchar) CopyMemory .yrwpassword (0), ByVal Srwpass, Len (SRWPASS)

Erase .yropassword () SROPASS = UCase $ (SROPASS & VBNULLCHAR) COPYMEMORY. Yropassword (0), ByVal Sropass, Len (Sropass) end with

Lreturn = netshareadd50 (Sservername, ShareElevel50, ShareInfo, Lenb (ShareInfo)

Debug.print "LRETURN:"; LRETURN

Createshare = LRETURNEND FUNCTION '******************************************************************************************************************************************************* * Public Function Deleteshare (Byval Ssharename As String) As long

DELETESHARE = ​​Netsharedelete ("", UCase $ (SSHARENAME), 0)

Debug.print "Lreturn:"; Deleteshare, "DLL Error:"; Err.lastdllerror

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-24259.html

New Post(0)