Announcement

Collapse
No announcement yet.

NET SEND alternative

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NET SEND alternative

    hi all,
    i've placed a little program on the source code forum: http://www.powerbasic.com/support/pb...ad.php?t=23138

    it is an alternative to the net send dos-command.
    it allows you to send messages to people who's pc has access
    to a certain common (network)directory.
    the messages you send to someone 'immediately' pop up on its pc's
    screen. you can hide the program so it does not occupy any space
    on the taskbar, but it still continues its task.

    it's important in this source code to set '$networkdrive' to the
    right networkdrive which every user of this program must have access to
    (read/write) .
    kind regards
    eddy


    ------------------
    [email protected]
    Eddy

  • #2
    Thanks for the tip. A much better way is to perform the exact same function that "net send" but programmatically, ie. open a mailslot on the receiving end and launch a timer, open a filehandle to the remote host from the sending side, let the timer check for incoming msgs on the receiving end and display any msg. I'm not through writing all the features that I wanted, so didn't upload the code yet, but here's the meat of the program:
    Code:
    'Listening application ---------------
    
    	Call SetTimer(hDlg, BYVAL &H0000FEED, 1000, BYVAL %NULL)
    
          'Listen for incoming msgs
    	lMailSlotHdl = CreateMailslot ("\\.\mailslot\messngr",0&, %MAILSLOT_WAIT_FOREVER, BYVAL %NULL)
    
          'Let the timer check for the msg queue every second
          Case %WM_TIMER
    		LOCAL lCharsToRead AS LONG, sFrom AS String
    		LOCAL sRaw AS String
    				
    		lResult = GetMailslotInfo (lMailSlotHdl,BYVAL %NULL, lSizeText,lMsgCount, BYVAL %NULL )
    			
    		lCharsToRead = lSizeText
    		If (lCharsToRead > 0) Then
    			sRaw = ReadMailSlot (lCharsToRead)
    			sFrom = PARSE$(sRaw, "$)B",1)
    			sMsg= PARSE$(sRaw, "$)B",3)
    			CONTROL SET TEXT CBHNDL, %IDC_EDIT, sMsg
    		End If
    
    	'ReadMailSlot
    	pMyAdd = VARPTR(sGr)
    	lResult = ReadFile (lMailSlotHdl, sGr,lToRead,lToRead,BYVAL %NULL)
    
    	For iIndex = 0 to lToRead - 1
    		If PEEK$(pMyAdd + iIndex,1) = chr$(0) Then
    			sText= sText+ "$)B"
    		Else
    			sText = sText + PEEK$(pMyAdd + iIndex,1)
    		End If
    	Next iIndex
    	ReadMailSlot = sText
    
    
    	lResult = CloseHandle(lMailSlotHdl)
    
    	KillTimer hDlg, &H0000FEED
    
    'Sending application ----------------------
    	lFileHdl = CreateFile ("\\" + sTo + "\mailslot\messngr",%GENERIC_WRITE, %FILE_SHARE_READ, BYVAL %NULL,%OPEN_EXISTING, _
    
    	lCharactersSent = (Len(sFrom) + 1) + (Len(sTo) + 1) + Len(sText)
    	sText = sFrom + chr$(0) + sTo + chr$(0) + sText
    	lResult = WriteFile (lFileHdl, sText, lCharactersSent, lCharactersSent, BYVAL %NULL)
    My ¥.2
    FF.

    ------------------

    Comment


    • #3
      also see net send in win9x.
      If you try to make something idiot-proof, someone will invent a better idiot.

      Comment


      • #4
        Incidently, I have found using "net send" or NetMessageBufferSend to be slower than going for mailslots directly. It's not a name resolution issue (WINS installed; local master browser OK;net view works fine), so have no idea why that API sometimes waits for about 10s before actually sending the message. The issue went away since using mailslots programmatically.

        FF.

        ------------------

        Comment


        • #5
          Frederic,
          Nice that you have found another NET SEND alternative.
          Personally, I had never heard of mailslots, so I solved my problem with the
          knowledge I had...
          Kind regards
          Eddy



          ------------------
          [email protected]
          Eddy

          Comment


          • #6
            Started the same way, but looked into mailslots because of that 10s delay.

            Mailslots are the way the "net send" or WinPopup send messages. Using mailslots is not any different from using the above or the NetMessageBufferSend() API. Do remember that the Net*() APIs use Unicode strings.

            More infos on mailslots: http://msdn.microsoft.com/library/de...lslot_7gj7.asp

            FF.

            ------------------

            Comment


            • #7
              Frederic,
              thanks for the info!
              Eddy

              ------------------
              [email protected]
              Eddy

              Comment

              Working...
              X