Results 1 to 2 of 2

Thread: net send...

  1. #1

    Thread Starter
    Lively Member Owen Holiday's Avatar
    Join Date
    Mar 2001
    Location
    back where I started.
    Posts
    71

    Unhappy

    Does anyonw know if there is any way to create a program that can detect when the "net send" function is used on the WinNT network, so that when the program is running, it can detect if there is a message is sent to that machine.

    Any suggestions at all would be greatly appreciated...

    Owen.
    "Programmers by passion, profession and insanity.
    Insane from the irrational, illogical and VB."- ThreeMinds

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Right then.
    The pop-up window has the title "Messenger Service" so you need to get titles of all the running apps and then loop through them to find it

    I've just put a Msgbox here when it is found.


    paste this into a module and call it from a timer control or a timer() loop

    Code:
    Option Explicit
    '/////////////////////////stuff for checking other windows///////////////////////////////////////
    Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
    Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal LParam As Long) As Long
    Private handles() As Long
    
    Public Counter As Long
    
    
    Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal LParam As Long) As Long
        Dim sCaption As String * 255
        ReDim Preserve handles(Counter)
        handles(Counter) = hwnd
        Counter = Counter + 1
        EnumWindowsProc = hwnd
    End Function
    Public Sub GetWindows()
    Dim textlen As Long  ' receives length of text of the window
    Dim wintext As String  ' receives the text of the window
    Dim slength As Long  ' receives the length of the returned string
    Dim n As Long
    Dim i As Integer
        
        ReDim handles(0)
        Counter = 0
        Call EnumWindows(AddressOf EnumWindowsProc, 0&)
       
      
        For n = 0 To UBound(handles())
          ' Find out how many characters are in the window's text.
          ' Add 1 to compensate for the terminating null.
          textlen = GetWindowTextLength(handles(n)) + 1
          ' Make sufficient room in the buffer.
          wintext = Space(textlen)
          ' Retrieve the text of window Form1.
          slength = GetWindowText(handles(n), wintext, textlen)
          
          
          'Debug.Print wintext
          ' Remove the empty space from the string, if any.
          wintext = Left(wintext, slength)
          If wintext <> "" Then
           Debug.Print wintext
          End If
          ' Display the result.
          If Trim(wintext) = "Messenger Service" Then
           '
            MsgBox "message recieved"
          End If
        Next n
    End Sub
       
    '////////////////////////////////////////////////////////////////
    Mark
    -------------------

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