Click here to Skip to main content
15,922,894 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralShortcut Key not working Pin
suchi-gupta5-Jun-05 19:16
suchi-gupta5-Jun-05 19:16 
GeneralInet Events not Triggering Pin
sparks805-Jun-05 12:15
sparks805-Jun-05 12:15 
Questionhow to implement ad-hoc network via WiFi in pocket pc Pin
Anonymous5-Jun-05 7:47
Anonymous5-Jun-05 7:47 
GeneralOutput Dos Command to HTML from HTML Pin
Lordahdaring5-Jun-05 5:04
Lordahdaring5-Jun-05 5:04 
GeneralRe: Output Dos Command to HTML from HTML Pin
toxcct5-Jun-05 5:17
toxcct5-Jun-05 5:17 
GeneralNetSessionEnum API example in VB.NET Pin
enesaga1235-Jun-05 3:15
enesaga1235-Jun-05 3:15 
GeneralRe: NetSessionEnum API example in VB.NET Pin
Paul_Taylor8-Jun-05 16:47
Paul_Taylor8-Jun-05 16:47 
GeneralRe: NetSessionEnum API example in VB.NET Pin
Paul_Taylor9-Jun-05 19:58
Paul_Taylor9-Jun-05 19:58 
Give this a try:


'Structures
'Requirements as of March 2005.
'Client : Windows XP, Windows 2000 Professional, or Windows NT Workstation.
'Server : Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Private Structure SHARE_SESSION_VALUES_502
Dim strComputerName As String 'The name of the computer that established the session.
Dim strUserName As String 'The name of the user who established the session.
Dim strNum_Opens As String 'The number of files, devices, and pipes opened during the session.
Dim strTime As String 'The number of seconds the session has been active.
Dim strIdle_Time As String 'The number of seconds the session has been idle.
Dim strUser_Flags As String 'Describes how the user established the session.
Dim strClientType As String 'The type of client that established the session.
Dim strTransport As String 'The name of the transport that the client is using to communicate with the server.
End Structure

Private Structure SHARE_SESSION_INFO_502
Dim strComputerName As IntPtr
Dim strUserName As IntPtr
Dim strNum_Opens As IntPtr
Dim strTime As IntPtr
Dim strIdle_Time As IntPtr
Dim strUser_Flags As IntPtr
Dim strClientType As IntPtr
Dim strTransport As IntPtr
End Structure


'Constants
Private Const NERR_SUCCESS As Long = 0
Private Const ERROR_MORE_DATA As Long = 234

'Variables
Private m_colSessionDetails As New Collection
Private m_strComputer As String
Private m_lngSessionLevel As Long

Public Sub Initialise(ByVal p_strComputerName As String)
Dim lngLoop As Long

m_strComputer = p_strComputerName
' Connect to the remote computer
test(p_strComputerName)
End Sub

Private Sub test(ByVal p_strComputer As String)
Dim p_lngRtn As Long
Dim p_intptrBuffer As IntPtr

Dim p_lngPreMaxLen As Long
Dim p_lngEntriesRead As Long
Dim p_lngTotalEntries As Long
Dim p_lngResumeHwnd As Long
Dim p_intPtrNextBuffer As IntPtr
Dim p_strClientName As String
Dim p_strUserName As String
Dim Share_Struct_Size As Integer

Dim SI502_Pointers As SHARE_SESSION_INFO_502
Dim SI502_Values As SHARE_SESSION_VALUES_502

Const cnstProcName As String = "Test"
Try

Do While m_colSessionDetails.Count > 0
m_colSessionDetails.Remove(1)
Loop

p_strComputer = "\\" & p_strComputer
p_strClientName = ""
p_strUserName = ""
p_lngPreMaxLen = 0
p_lngResumeHwnd = 0
'Try the Win XP, 2000 Server and 2003 Server option first, if that fails - then try
'the option for Win Me, 98, and 95.
m_lngSessionLevel = 502
p_lngRtn = NetSessionEnum(p_strComputer, _
p_strClientName, _
p_strUserName, _
m_lngSessionLevel, _
p_intptrBuffer, _
p_lngPreMaxLen, _
p_lngEntriesRead, _
p_lngTotalEntries, _
p_lngResumeHwnd)
If p_lngRtn = NERR_SUCCESS Then
If p_lngRtn <> ERROR_MORE_DATA Then
Share_Struct_Size = Marshal.SizeOf(SI502_Values)
For i As Integer = 0 To p_lngEntriesRead - 1
p_intPtrNextBuffer = New IntPtr(p_intptrBuffer.ToInt32 + (Share_Struct_Size * i))
SI502_Pointers = Marshal.PtrToStructure(p_intPtrNextBuffer, GetType(SHARE_SESSION_INFO_502))
SI502_Values = New SHARE_SESSION_VALUES_502
SI502_Values.strComputerName = Marshal.PtrToStringUni(SI502_Pointers.strComputerName)
SI502_Values.strUserName = Marshal.PtrToStringUni(SI502_Pointers.strUserName)
SI502_Values.strNum_Opens = SI502_Pointers.strNum_Opens.ToInt32
SI502_Values.strTime = SI502_Pointers.strTime.ToInt32
SI502_Values.strIdle_Time = SI502_Pointers.strIdle_Time.ToInt32
SI502_Values.strUser_Flags = SI502_Pointers.strUser_Flags.ToInt32
SI502_Values.strClientType = Marshal.PtrToStringUni(SI502_Pointers.strClientType)
SI502_Values.strTransport = Marshal.PtrToStringUni(SI502_Pointers.strTransport)
m_colSessionDetails.Add(SI502_Values)
Next
End If
Else
'TODO - Enumerate Sessions using level 50.
m_lngSessionLevel = 50
End If

'Clean up the buffer
Call NetAPIBufferFree(p_intptrBuffer)
Call NetAPIBufferFree(p_intPtrNextBuffer)
Exit Sub

Catch e As Exception
Err.Raise(p_lngRtn, _
cnstProcName, _
e.Message)
End Try

End Sub


Regards,
Paul T.
GeneralRe: NetSessionEnum API example in VB.NET Pin
enesaga12311-Jun-05 2:52
enesaga12311-Jun-05 2:52 
GeneralRe: NetSessionEnum API example in VB.NET Pin
Paul_Taylor13-Jun-05 13:00
Paul_Taylor13-Jun-05 13:00 
GeneralGetting text from picture Pin
Vertyg05-Jun-05 2:57
Vertyg05-Jun-05 2:57 
GeneralRe: Getting text from picture Pin
Dave Kreskowiak5-Jun-05 9:52
mveDave Kreskowiak5-Jun-05 9:52 
Generaldoing console operations through VB.NET windows application Pin
fayaz ahamed5-Jun-05 1:25
fayaz ahamed5-Jun-05 1:25 
GeneralRe: doing console operations through VB.NET windows application Pin
Dave Kreskowiak5-Jun-05 9:47
mveDave Kreskowiak5-Jun-05 9:47 
GeneralRe: doing console operations through VB.NET windows application Pin
fayaz ahamed5-Jun-05 18:51
fayaz ahamed5-Jun-05 18:51 
GeneralRe: doing console operations through VB.NET windows application Pin
Scott Serl5-Jun-05 11:11
Scott Serl5-Jun-05 11:11 
GeneralRe: doing console operations through VB.NET windows application Pin
albCode6-Jun-05 0:55
albCode6-Jun-05 0:55 
GeneralRe: doing console operations through VB.NET windows application Pin
fayaz ahamed7-Jun-05 18:14
fayaz ahamed7-Jun-05 18:14 
GeneralView Picture Pin
ksampatlall4-Jun-05 23:32
ksampatlall4-Jun-05 23:32 
GeneralRe: View Picture Pin
Christian Graus5-Jun-05 12:52
protectorChristian Graus5-Jun-05 12:52 
GeneralFlag Pin
lijocm4-Jun-05 21:09
lijocm4-Jun-05 21:09 
GeneralRe: Flag Pin
WillemM5-Jun-05 0:52
WillemM5-Jun-05 0:52 
GeneralRe: Flag Pin
toxcct5-Jun-05 3:56
toxcct5-Jun-05 3:56 
Generalhard code session cookie Pin
unclejoe4-Jun-05 15:34
unclejoe4-Jun-05 15:34 
GeneralA simple question about form Pin
Anonymous4-Jun-05 12:41
Anonymous4-Jun-05 12:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.