Results 1 to 8 of 8

Thread: detect lan activity

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    detect lan activity

    i want to detect if a computer on the LAN is trying to access another computer on the LAN is this possible?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Since I know you like Winsock, couldn't you write something that
    has ports open on each computer listening and when another
    computer connects you could send something to the server app?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    what port does the lan work on?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I'm not sure but I thought about it again and I don't know if this
    is a vaild possible solution. I thought there was an API for
    detecting network activity?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    This example may have some use? The USER_INFO_3 type
    has some good stuff in it.

    VB Code:
    1. Const NERR_Success = 0
    2. Private Const NERR_BASE = 2100
    3. Private Const NERR_InvalidComputer = (NERR_BASE + 251)
    4. Private Const NERR_UseNotFound = (NERR_BASE + 150)
    5. Const CP_ACP = 0
    6. Private Type USER_INFO_3
    7.     usri3_name As Long
    8.     usri3_password As Long
    9.     usri3_password_age As Long
    10.     usri3_priv As Long
    11.     usri3_home_dir As Long
    12.     usri3_comment As Long
    13.     usri3_flags As Long
    14.     usri3_script_path As Long
    15.     usri3_auth_flags As Long
    16.     usri3_full_name As Long
    17.     usri3_usr_comment As Long
    18.     usri3_parms As Long
    19.     usri3_workstations As Long
    20.     usri3_last_logon As Long
    21.     usri3_last_logoff As Long
    22.     usri3_acct_expires As Long
    23.     usri3_max_storage As Long
    24.     usri3_units_per_week As Long
    25.     usri3_logon_hours As Byte
    26.     usri3_bad_pw_count As Long
    27.     usri3_num_logons As Long
    28.     usri3_logon_server As String
    29.     usri3_country_code As Long
    30.     usri3_code_page As Long
    31.     usri3_user_id As Long
    32.     usri3_primary_group_id As Long
    33.     usri3_profile As Long
    34.     usri3_home_dir_drive As Long
    35.     usri3_password_expired As Long
    36. End Type
    37. Private Declare Function NetUserGetInfo Lib "netapi32" (lpServer As Any, UserName As Byte, ByVal Level As Long, lpBuffer As Long) As Long
    38. Private Declare Function NetApiBufferFree Lib "netapi32" (ByVal Buffer As Long) As Long
    39. Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)
    40. Private Declare Function lstrlenW Lib "kernel32" (lpString As Any) As Long
    41. Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal codepage As Long, ByVal dwFlags As Long, lpWideCharStr As Any, ByVal cchWideChar As Long, lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long
    42. ' Returns an ANSI string from a pointer to a Unicode string.
    43. Public Function GetStrFromPtrW(lpszW As Long) As String
    44.     Dim sRtn As String
    45.     sRtn = String$(lstrlenW(ByVal lpszW) * 2, 0)   ' 2 bytes/char
    46.     ' WideCharToMultiByte also returns Unicode string length
    47.     Call WideCharToMultiByte(CP_ACP, 0, ByVal lpszW, -1, ByVal sRtn, Len(sRtn), 0, 0)
    48.     GetStrFromPtrW = GetStrFromBufferA(sRtn)
    49. End Function
    50. ' Returns the string before first null char encountered (if any) from an ANSII string.
    51. Public Function GetStrFromBufferA(sz As String) As String
    52.     If InStr(sz, vbNullChar) Then
    53.         GetStrFromBufferA = Left$(sz, InStr(sz, vbNullChar) - 1)
    54.     Else
    55.         ' If sz had no null char, the Left$ function
    56.         ' above would return a zero length string ("").
    57.         GetStrFromBufferA = sz
    58.     End If
    59. End Function
    60. Private Sub Form_Load()
    61.     'KPD-Team 2001
    62.     'URL: [url]http://www.allapi.net/[/url]
    63.     'E-Mail: [email][email protected][/email]
    64.     Dim lpBuf As Long
    65.     Dim ui3 As USER_INFO_3
    66.     ' replace "Administrator" with a valid NT username
    67.     Dim bServer() As Byte, bUsername() As Byte
    68.     bServer = "" & vbNullChar
    69.     bUsername = "Administrator" & vbNullChar
    70.     If (NetUserGetInfo(bServer(0), bUsername(0), 3, lpBuf) = NERR_Success) Then
    71.         Call MoveMemory(ui3, ByVal lpBuf, Len(ui3))
    72.         MsgBox GetStrFromPtrW(ui3.usri3_name)
    73.         MsgBox GetStrFromPtrW(ui3.usri3_comment)
    74.         Call NetApiBufferFree(ByVal lpBuf)
    75.     End If
    76. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    The Logged on usertype property looks promissing.
    VB Code:
    1. Private Const PLATFORM_ID_DOS = 300
    2. Private Const PLATFORM_ID_OS2 = 400
    3. Private Const PLATFORM_ID_NT = 500
    4. Private Const PLATFORM_ID_OSF = 600
    5. Private Const PLATFORM_ID_VMS = 700
    6.  
    7. Private Type WKSTA_INFO_102
    8.    wki100_platform_id As Long
    9.    pwki100_computername As Long
    10.    pwki100_langroup As Long
    11.    wki100_ver_major As Long
    12.    wki100_ver_minor As Long
    13.    pwki102_lanroot As Long
    14.    [color=red]wki102_logged_on_users[/color] As Long
    15. End Type
    16.  
    17. Declare Function NetWkstaGetInfo Lib "netapi32" (ByVal servername As String, ByVal level As Long, lpBuf As Any) As Long
    18. Declare Function NetApiBufferFree Lib "netapi32" (ByVal Buffer As Long) As Long
    19. Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
    20. Sub Main()
    21.    'code submitted by Andreas Linnemann ([email protected])
    22.    Dim pWrkInfo As Long, WrkInfo(0) As WKSTA_INFO_102, lResult As Long
    23.    'make sure you replace the value of the following constant
    24.    'with a valid computer name from your LAN
    25.    Const strComputername = "YourComputerName"
    26.    lResult = NetWkstaGetInfo(StrConv("\\" & strComputername, vbUnicode), 102, pWrkInfo)
    27.    If lResult = 0 Then
    28.       Dim cname As String
    29.       cname = String$(255, 0)
    30.       CopyMemory WrkInfo(0), ByVal pWrkInfo, ByVal Len(WrkInfo(0))
    31.       CopyMemory ByVal cname, ByVal WrkInfo(0).pwki100_langroup, ByVal 255
    32.       Debug.Print "Domain: " & StripTerminator(StrConv(cname, vbFromUnicode))
    33.       Debug.Print "Operating System: ";
    34.       Select Case WrkInfo(0).wki100_platform_id
    35.          Case PLATFORM_ID_DOS: Debug.Print "DOS"
    36.          Case PLATFORM_ID_OS2:
    37.                      If WrkInfo(0).wki100_ver_major = "4" Then
    38.                         Debug.Print "Win9x"
    39.                      Else
    40.                         Debug.Print "OS2"
    41.                      End If
    42.          Case PLATFORM_ID_NT:
    43.                      If WrkInfo(0).wki100_ver_major = "5" Then
    44.                         Debug.Print "Win 2000"
    45.                      Else
    46.                         Debug.Print "Win NT"
    47.                      End If
    48.          Case PLATFORM_ID_OSF: Debug.Print "OSF"
    49.          Case PLATFORM_ID_VMS: Debug.Print "VMS"
    50.       End Select
    51.       Debug.Print " Version "; WrkInfo(0).wki100_ver_major; "."; WrkInfo(0).wki100_ver_minor
    52.       Debug.Print "Lan Root: ";
    53.       cname = String$(255, 0)
    54.       CopyMemory ByVal cname, ByVal WrkInfo(0).pwki102_lanroot, ByVal 255
    55.       Debug.Print StripTerminator(StrConv(cname, vbFromUnicode))
    56.       Debug.Print "Logged User: "; Str$(WrkInfo(0).wki102_logged_on_users), vbBlack
    57.       NetApiBufferFree ByVal pWrkInfo
    58.    End If
    59. End Sub
    60. 'This function is used to stripoff all the unnecessary chr$(0)'s
    61. Private Function StripTerminator(sInput As String) As String
    62.     Dim ZeroPos As Integer
    63.     'Search the first chr$(0)
    64.     ZeroPos = InStr(1, sInput, vbNullChar)
    65.     If ZeroPos > 0 Then
    66.         StripTerminator = Left$(sInput, ZeroPos - 1)
    67.     Else
    68.         StripTerminator = sInput
    69.     End If
    70. End Function
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    ok thanks for your help i'm going to look into it

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    If you get the solution, I would like to know too.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width