Click to See Complete Forum and Search --> : Problem with sending messages over a network


Cakkie
February 21st, 2000, 05:14 AM
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
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

Lothar Haensler
February 21st, 2000, 06:09 AM
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.

Kyle Burns
February 21st, 2000, 09:25 AM
One solution would be to shell out "net send [computername|username] messagetext"