NetShareDel The NetShareDel function deletes a share name from a server's list of shared resources, disconnecting all connections to the shared resource.Security Requirements Only members of the Administrators or Account Operators local group or those with Communication, Print, or Server operator group membership can successfully execute NetShareDel. The Print operator can delete only Printer queues. The Communication operator can delete only communication-device queues.NET_API_STATUS NetShareDel( LPWSTR servername, LPWSTR netname, DWORD reserved );
Parameters servername Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer. netname Pointer to a Unicode string containing the network name of the share to delete. reserved Reserved, must be zero. Return Values If the function returns account information, the return value is NERR_Success.If the function fails, the return value is one of the following error codes.Value Meaning
ERROR_ACCESS_DENIED The user does not have access to the requested information. ERROR_INVALID_PARAMETER The specified parameter is invalid. ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available. NERR_NetNameNotFound The sharename does not exist. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Unsupported. Header: Declared in lmshare.h. Import Library: Use netapi32.lib (Windows NT) or svrapi.lib (Windows 95).See Also Networking (Net) Overview, Net Functions, NetShareAdd
yonghengdizhen(等季节一过,繁花就凋落') 能贴出例子来吗? 非常感谢拉
to ryuginka(ryuginka): fso怎么用呢?我只要实现把共享删除就可以了,用哪种方法都没关系,关键是要自动,并且即使该目录已经有人打开也可以删除共享,而且要不重启
我已经实现了,哈哈,就是用的 '删除共享(返回0 表示成功) '参数: 'sServer 计算机名 'sShareName 共享名 Private Function DelShare(sServer As String, _ sShareName As String) As Long
Dim lngServer As Long '计算机名 Dim lngNetname As Long '共享名 lngServer = StrPtr(sServer) '转成地址 lngNetname = StrPtr(sShareName) '删除共享 DelShare = NetShareDel(lngServer, lngNetname, 0)大家一起来试试吧。呵呵,结贴喽
The NetShareDel function deletes a share name from a server's list of shared resources, disconnecting all connections to the shared resource.Security Requirements
Only members of the Administrators or Account Operators local group or those with Communication, Print, or Server operator group membership can successfully execute NetShareDel. The Print operator can delete only Printer queues. The Communication operator can delete only communication-device queues.NET_API_STATUS NetShareDel(
LPWSTR servername,
LPWSTR netname,
DWORD reserved
);
Parameters
servername
Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.
netname
Pointer to a Unicode string containing the network name of the share to delete.
reserved
Reserved, must be zero.
Return Values
If the function returns account information, the return value is NERR_Success.If the function fails, the return value is one of the following error codes.Value Meaning
ERROR_ACCESS_DENIED The user does not have access to the requested information.
ERROR_INVALID_PARAMETER The specified parameter is invalid.
ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available.
NERR_NetNameNotFound The sharename does not exist.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in lmshare.h.
Import Library: Use netapi32.lib (Windows NT) or svrapi.lib (Windows 95).See Also
Networking (Net) Overview, Net Functions, NetShareAdd
非常感谢拉
fso怎么用呢?我只要实现把共享删除就可以了,用哪种方法都没关系,关键是要自动,并且即使该目录已经有人打开也可以删除共享,而且要不重启
'删除共享(返回0 表示成功)
'参数:
'sServer 计算机名
'sShareName 共享名
Private Function DelShare(sServer As String, _
sShareName As String) As Long
Dim lngServer As Long '计算机名
Dim lngNetname As Long '共享名 lngServer = StrPtr(sServer) '转成地址
lngNetname = StrPtr(sShareName) '删除共享
DelShare = NetShareDel(lngServer, lngNetname, 0)大家一起来试试吧。呵呵,结贴喽