Function Reference


_Net_Share_FileEnum

Returns information about open files on a server

#include <NetShare.au3>
_Net_Share_FileEnum ( [$sServer = "" [, $sBaseName = "" [, $sUserName = ""]]] )

Parameters

$sServer [optional] String that contains the name of the server on which the function is to execute.
A blank specifies the local computer.
$sBaseName [optional] String containing a qualifier for the returned information.
If blank all open resources are enumerated.
If not blank, the function enumerates only resources that have $sBaseName as a prefix.
$sUserName [optional] String that specifies the name of the user.
If not blank $sUserName serves as a qualifier to the enumeration.

Return Value

Success: an array with the following format:
    [0][0] - Number of entries in the array (n)
    [1][0] - ID number assigned to the resource when it is opened
    [1][1] - Access permissions associated with the opening application:
        1 - Permission to read a resource and execute the resource
        2 - Permission to write to a resource.
        4 - Permission to create a resource
        8 - Execute permission
        16 - Delete permission
        32 - Change attribute permission
        64 - Change ACL permission
    [1][2] - Contains the number of file locks on the resource
    [1][3] - Specifies the path of the opened resource
    [1][4] - Specifies which user or which computer opened the resource
Failure: sets the @error flag to non-zero.

Remarks

Only members of the Administrators or Server Operators local group can execute this function.

Related

_Net_Share_ConnectionEnum, _Net_Share_SessionEnum, _Net_Share_ShareEnum

See Also

Search NetFileEnum in MSDN Library.

Example

#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])
        For $iI = 1 To $aInfo[0][0]
                MemoWrite("Resource ID .............: " & $aInfo[$iI][0])
                MemoWrite("Resource permissions ....: " & _Net_Share_PermStr($aInfo[$iI][1]))
                MemoWrite("Resource locks ..........: " & $aInfo[$iI][2])
                MemoWrite("Resource path ...........: " & $aInfo[$iI][3])
                MemoWrite("Resource user ...........: " & $aInfo[$iI][4])
                MemoWrite()
        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