↑  ←  Описание функции


_Net_Share_SessionEnum

Provides information about sessions established on a server

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

Параметры

$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.
$sClientName [необязательный] Specifies the name of the computer session for which information is to be returned. If this
    parameter is blank, the function returns information for all computer sessions on the server.
$sUserName [необязательный] Specifies the name of the user for which information is to be returned. If this parameter is
    blank, the function returns information for all users.

Возвращаемое значение

Успех:Возвращает массив следующего формата:
[0][0] - Number of entries in array
[1][0] - Name of the computer that established the session
[1][1] - Name of the user who established the session
[1][2] - Number of files, devices, and pipes opened during the session
[1][3] - Number of seconds the session has been active
[1][4] - Number of seconds the session has been idle
[1][5] - Specifies how the user established the session:
1 - User established session using a guest account
2 - User established session without using password encryption
[1][6] - Specifies the type of client that established the session
[1][7] - Name of the transport that the client is using
Ошибка:Устанавливает @error

Примечания

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

См. также

_Net_Share_ConnectionEnum, _Net_Share_FileEnum, _Net_Share_ShareEnum

См. также

Искать NetSessionEnum в библиотеке MSDN

Пример

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

Global $iMemo

_Main()

Func _Main()
    Local $hGUI, $sServer, $aInfo

    ; Создаёт GUI
    $hGUI = GUICreate("NetShare", 400, 300)

    ; Создаёт элемент для заметок
    $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    ; Enumerate network sessions
    $aInfo = _Net_Share_SessionEnum ($sServer, @ComputerName)
    MemoWrite("Error ..........: " & @error)
    MemoWrite("Entries read ...: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Computer name ..: " & $aInfo[$iI][0])
        MemoWrite("User name.......: " & $aInfo[$iI][1])
        MemoWrite("Resources open .: " & $aInfo[$iI][2])
        MemoWrite("Seconds active .: " & $aInfo[$iI][3])
        MemoWrite("Seconds idle ...: " & $aInfo[$iI][4])
        MemoWrite("Connection type : " & $aInfo[$iI][5])
        MemoWrite("Client type ....: " & $aInfo[$iI][6])
        MemoWrite("Transport ......: " & $aInfo[$iI][7])
        MemoWrite()
    Next

    ; Цикл выполняется, пока окно не будет закрыто
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

; Записывает строку в элемент для заметок
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite