Function Reference


_Net_Share_ConnectionEnum

Lists all connections made to a shared resource

#include <NetShare.au3>
_Net_Share_ConnectionEnum ( $sServer, $sQualifier )

Parameters

$sServer String that 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.
$sQualifier Specifies a share name or computer name of interest.
If it is a share name, then all of the connections made to that share name are listed.
If it is a computer name, the function lists all connections made from that computer to the server specified.

Return Value

Success: an array with the following format:
    [0][0] - Number of entries in array
    [1][0] - Connection identification number
    [1][1] - Type of connection. Can be combination of:
        $STYPE_DISKTREE - Disk drive
        $STYPE_PRINTQ - Print queue
        $STYPE_DEVICE - Communication device
        $STYPE_IPC - IPC
        $STYPE_SPECIAL - Special share reserved for IPC$ or remote administration of the server
        $STYPE_TEMPORARY - A temporary share
    [1][2] - Number of files currently open as a result of the connection
    [1][3] - Number of users on the connection
    [1][4] - Number of seconds that the connection has been established
    [1][5] - If the server sharing the resource is running with user level security, this member describes which user made the connection. If the server is running with share level security, this member describes which computer made the connection.
    [1][6] - Specifies either the share name of the server's shared resource or the computername of the client
Failure: sets the @error flag to non-zero.

Remarks

Administrator, Server or Print Operator or Power User group membership is required to execute this function

Related

_Net_Share_FileEnum, _Net_Share_SessionEnum, _Net_Share_ShareEnum

See Also

Search NetConnectionEnum in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
        Local $sServer, $sShare, $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
        $sShare = InputBox("NetWork Demo", "Enter Share Name:", "MyShare", "", 200, 130)
        If @error Then Exit

        ; Enumerate network connections
        $aInfo = _Net_Share_ConnectionEnum($sServer, $sShare)
        MemoWrite("Error ...................: " & @error)
        MemoWrite("Entries read ............: " & $aInfo[0][0])
        For $iI = 1 To $aInfo[0][0]
                MemoWrite("Connection ID ...........: " & $aInfo[$iI][0])
                MemoWrite("Connection type..........: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
                MemoWrite("Number of files open ....: " & $aInfo[$iI][2])
                MemoWrite("Number of users .........: " & $aInfo[$iI][3])
                MemoWrite("Connection time .........: " & $aInfo[$iI][4])
                MemoWrite("Username ................: " & $aInfo[$iI][5])
                MemoWrite("Network name ............: " & $aInfo[$iI][6])
                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