Results 1 to 2 of 2

Thread: Sending a message with API

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Location
    Belgium
    Posts
    13
    Morning everybody,

    Can someone give me a bit of help, I try to send a message over a local network using API, but if I do it the way the original author suggested it wont work, if I use two times the messagevariabel the message comes true, but the usernamefrom is replaced with the machinenumber.

    If I do it using the parameters "UserTo,UserFrom,Message", the message won't be sent, instate the username USERFRom will be displayed as a message.
    I can't find out what's wrong.

    Private Declare Function NetMessageBufferSend Lib "Netapi32.dll" _
    (yServer As Any, yToName As Byte, yFromName As Any, yMsg As Byte, _
    ByVal lSize As Long) As Long
    Private Const Nerr_Success As Long = 0&
    -------------------------------------------------------
    Public Sub Sturen()
    Dim antw As Boolean
    Dim message As String
    Dim UserToSend As String
    Static i As Integer
    message = "Hello World"
    For i = LBound(UserId) To UBound(UserId)
    UserToSend = UserId(i)

    /////////////////////////////////////////////////////////////////////
    antw = BroadCastMessage(UserToSend, message, message)
    /////////////////////////////////////////////////////////////////////
    Next
    For i = LBound(UserId) To UBound(UserId)
    UserId(i) = ""
    Next
    End Sub
    -------------------------------------------------------------------
    Public Function BroadCastMessage(UserOrMachine As String, _
    FromName As String, message As String) As Boolean

    Dim ToName() As Byte
    Dim FromName2() As Byte
    Dim MessageToSend() As Byte

    ToName = UserOrMachine & vbNullChar
    FromName2 = FromName & vbNullChar
    MessageToSend = message & vbNullChar

    If NetMessageBufferSend(ByVal 0&, ToName(0), ByVal 0&, _
    FromName2(0), UBound(MessageToSend)) = Nerr_Success Then
    BroadCastMessage = True
    End If
    End Function
    --------------------------------------------------------------

  2. #2
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    umm,
    antw = BroadCastMessage(UserToSend, message, message)

    dont you mean
    antw = BroadCastMessage(UserToSend, fromUser, message)


    and also i think you;re using the api incorrectly... it doesnt make sense that you are passing in the "length" of the message instead of (a pointer to) the actual message.

    If NetMessageBufferSend(ByVal 0&, ToName(0), ByVal 0&, _
    FromName2(0), UBound(MessageToSend)) = Nerr_Success Then
    BroadCastMessage = True
    End If

    might want to try:
    If NetMessageBufferSend(ByVal 0&, ToName(0), ByVal 0&, _
    FromName2(0), MessageToSend(0)) = Nerr_Success Then
    BroadCastMessage = True
    End If

    i think ur missing "userFrom"???
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

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