Страница: 1 |
|
Вопрос: Аналог net session
|
Добавлено: 01.09.10 14:27
|
|
Автор вопроса: ANALYST
|
Здравствуйте!
Скажите пожалуйста как узнать все открытые сеансы на локальном компьютере для создания аналога команды "net session "?
Спасибо.
Ответить
|
Номер ответа: 1 Автор ответа: ANALYST
Вопросов: 3 Ответов: 12
|
Профиль | | #1
|
Добавлено: 02.09.10 09:00
|
Нашел функцию NetSessionEnum из "Netapi32.dll". Может есть пример его использования на VB.NET.
Я пишу
- Private Declare Function NetSessionEnum Lib "netapi32.dll" ( _
- ByVal servername As String, _
- ByVal UncClientName As String, _
- ByVal username As String, _
- ByVal level As Long, _
- ByVal bufptr As Long, _
- ByVal prefmaxlen As Long, _
- ByVal entriesread As Long, _
- ByVal totalentries As Long, _
- ByVal resume_handle As Long) As Long
-
- Private pszServerName As String = Nothing
- Private pszClientName As String = Nothing
- Private pszUserName As String = Nothing
- Private dwLevel As Long = 10
- Private bufptr As Long
- Private dwPrefMaxLen As Long = -1&
- Private dwEntriesRead As Long = 0
- Private dwTotalEntries As Long = 0
- Private dwResumeHandle As Long = 0
- ---------------------------------------------
- nStatus = NetSessionEnum(pszServerName, pszClientName, pszUserName, 10, bufptr, dwPrefMaxLen, dwEntriesRead, dwTotalEntries, dwResumeHandle)
Но вылетает с ошибкой на - nStatus = NetSessionEnum(pszServerName, pszClientName, pszUserName, 10, bufptr, dwPrefMaxLen, dwEntriesRead, dwTotalEntries, dwResumeHandle)
:
> PInvokeStackImbalance was detected
Message: A call to PInvoke function 'NetSessionEnum!NetSessionEnum.Form1::NetSessionEnum' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Ответить
|
Номер ответа: 3 Автор ответа: ANALYST
Вопросов: 3 Ответов: 12
|
Профиль | | #3
|
Добавлено: 02.09.10 13:45
|
Решил:
- Private Declare Function NetSessionEnum Lib "netapi32.dll" ( _
- <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal servername As String, _
- <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal UncClientName As String, _
- <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal username As String, _
- ByVal level As Long, _
- ByVal bufptr As IntPtr, _
- ByVal prefmaxlen As Long, _
- ByVal entriesread As Long, _
- ByVal totalentries As Long, _
- ByVal resume_handle As Long) As Long
-
-
- Private pszServerName As String = ""
- Private pszClientName As String = ""
- Private pszUserName As String = ""
- Private dwLevel As Long = 502
- Private bufptr As IntPtr = 0
- Private dwPrefMaxLen As Long = -1&
- Private dwEntriesRead As Long = 0
- Private dwTotalEntries As Long = 0
- Private dwResumeHandle As Long = 0
-
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- If pszServerName = "" Then pszServerName = "\\" & Environ$("COMPUTERNAME")
- Dim nStatus As Long = NetSessionEnum(pszServerName, pszClientName, pszUserName, dwLevel, bufptr, dwPrefMaxLen, dwEntriesRead, dwTotalEntries, dwResumeHandle)
- MsgBox(nStatus)
- End Sub
Ответить
|
Номер ответа: 4 Автор ответа: ANALYST
Вопросов: 3 Ответов: 12
|
Профиль | | #4
|
Добавлено: 03.09.10 14:47
|
А как теперь узнать время простоя сеанса?
Ответить
|
Страница: 1 |
Поиск по форуму