CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Problem with sending messages over a network

    I'm using this code to send a message over the network. There is only one problem:
    It only works if I try to send a message to myself, when I try to message another pc or user on the network, it does not work. All the PC's are running WINNT 4

    private Declare Function NetMessageBufferSend Lib "netapi32.dll" (byval ServerName as string, byval MsgName as string, byval FromName as string, Buf as Any, BufLen as Long) as Long

    private Sub sendNetMsg(byval strTo as string,byval strFrom as string, strMessage as string)

    Dim sName as string
    dim sMsg as string
    dim sBuf as string
    Dim lLen as long
    dim ret as long

    sNameFrom = StrConv(strFrom, vbUnicode)
    sNameTo = StrConv(strTo, vbUnicode)
    sMsg = StrConv(strFrom, vbUnicode)
    sBuf = StrConv(strMessage, vbUnicode)
    lLen = LenB(sBuf)
    ret = NetMessageBufferSend(sNameTo, sMsg, sNameFrom, byval sBuf, byval lLen)

    End Sub




    Tom Cannaerts
    [email protected]

    The best way to escape a problem, is to solve it.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Problem with sending messages over a network

    check the return code. It will tell you why it didn't work.

    IMHO the first parameter should be NULL, unless you want to execute that function on a remote server.


  3. #3
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: Problem with sending messages over a network

    One solution would be to shell out "net send [computername|username] messagetext"


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

Featured