Forces a resource to close
#include <NetShare.au3>
_Net_Share_FileClose ( $sServer, $iFileID )
$sServer | Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank, the local computer is used. |
$iFileID | Specifies the file identifier of the opened resource instance to close |
Success: | True. |
Failure: | False. |
Only members of the Administrators or Server Operators local group can execute this function.
Search NetFileClose in MSDN Library.
#include <GUIConstantsEx.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>
Global $g_idMemo
Example()
Func Example()
Local $sServer, $aInfo
; Create GUI
GUICreate("NetShare", 400, 300)
; Create memo control
$g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
GUISetState(@SW_SHOW)
; Get server and share information
$sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
If @error Then Exit
; Enumerate open files on the server
$aInfo = _Net_Share_FileEnum($sServer)
MemoWrite("Error ...................: " & @error)
MemoWrite("Entries read ............: " & $aInfo[0][0])
; Force close any file open named "Test.txt"
For $iI = 1 To $aInfo[0][0]
If StringInStr($aInfo[$iI][3], "Test.txt") > 0 Then
_Net_Share_FileClose($sServer, $aInfo[$iI][0])
MemoWrite("Closed file")
EndIf
Next
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>Example
; Write message to memo
Func MemoWrite($sMessage = "")
GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite