共享服务器资源
#Include <NetShare.au3>
_Net_Share_ShareSetInfo($sServer, $sShare, $sComment, $iMaxUses)
$sServer | 指定 DNS 或 NetBIOS 远程服务器上执行函数的名称 如果此参数为空, 在本地计算机上使用. |
$sShare | 指定设置信息的共享名称 |
$sComment | 共享资源的可选注释 |
$iMaxUses | 资源所能容纳的最大连接数量. 如果这个值是 -1,则连接数是无限的. |
成功: | 返回 True |
失败: | 返回 False |
在MSDN中搜索
#include <GUIConstantsEx.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>
Global $iMemo
_Main()
Func _Main()
Local $aInfo
Local Const $sShareName = "AutoIt Share"
; 创建 GUI
GUICreate("NetShare", 400, 300)
; 创建 memo 控件
$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
; See if the share exists
If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
; Create a share on the local computer
_Net_Share_ShareAdd(@ComputerName, $sShareName, 0, "C:\", "AutoIt Share Comment")
If @error Then MsgBox(4096, "信息", "Share add error : " & @error)
MemoWrite("Share added")
Else
MemoWrite("Share exists")
EndIf
; Change share information
_Net_Share_ShareSetInfo(@ComputerName, $sShareName, "New Comment", 4)
; Show information about the share we added
$aInfo = _Net_Share_ShareGetInfo(@ComputerName, $sShareName)
MemoWrite("Share name ..............: " & $aInfo[0])
MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[1]))
MemoWrite("Comment .................: " & $aInfo[2])
MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[3]))
MemoWrite("Maximum connections .....: " & $aInfo[4])
MemoWrite("Current connections .....: " & $aInfo[5])
MemoWrite("Local path ..............: " & $aInfo[6])
MemoWrite("Password ................: " & $aInfo[7])
; Delete the share
_Net_Share_ShareDel(@ComputerName, $sShareName)
If @error Then MsgBox(4096, "信息", "Share delete error : " & @error)
MemoWrite("Share deleted")
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
; 写入消息到 memo
Func MemoWrite($sMessage = "")
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite