net send without using net send?

T

Thomas

hello,

i am searching for a while to use net send in vb.net without using the
commandline net send... is there an api, with an example... i know
that there is the possib. to send such messages over the lan with
another sender name - how can i do this ... is it possible in vb.net?

thanks
 
T

Thomas

thanks, it looks really good,but it doesn´t send any message... my
code is now(taken from your hint):

Public Class Form1
Dim ret As String
Private Declare Unicode Function NetMessageBufferSend Lib
"netapi32.dll" ( _
ByVal servername As String, _
ByVal msgname As String, _
ByVal fromname As String, _
ByVal msgbuf As String, _
ByVal msgbuflen As Int32 _
) As Int32

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strmessage As String = "testmessage..."
ret = NetMessageBufferSend("*", "testmsgname", "fromname",
strmessage, strmessage.Length * 2 + 2)
MsgBox(ret)
End Sub
End Class
 
H

Herfried K. Wagner [MVP]

Thomas said:
thanks, it looks really good,but it doesn´t send any message... my
code is now(taken from your hint):
[...]
ret = NetMessageBufferSend("*",

The first parameter expects a server name. MSDN:
 
T

Thomas

i´m sorry, but i´ve done the changes, it doesn´t really work... - the
return code is 2273 ...do you know the return codes?

Public Class Form1
Dim ret As String
Private Declare Unicode Function NetMessageBufferSend Lib
"netapi32.dll" ( _
ByVal servername As String, _
ByVal msgname As String, _
ByVal fromname As String, _
ByVal msgbuf As String, _
ByVal msgbuflen As Int32 _
) As Int32

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strmessage As String = "testmessage..."
Const servername As String = vbNullString
ret = NetMessageBufferSend(servername, "testmsgname",
"fromname", strmessage, strmessage.Length * 2 + 2)
MsgBox(ret)
End Sub
End Class

Thomas said:
thanks, it looks really good,but it doesn´t send any message... my
code is now(taken from your hint):
[...]
ret = NetMessageBufferSend("*",

The first parameter expects a server name. MSDN:

---
Pointer to a constant string that specifies the DNS or NetBIOS name of the
remote server on which the function is to execute. If this parameter is
'NULL', the local computer is used.
Windows NT: This string must begin with "\\".
 
H

Herfried K. Wagner [MVP]

Thomas said:
i´m sorry, but i´ve done the changes, it doesn´t really work... - the
return code is 2273 ...do you know the return codes?

That's 'NNERR_NameNotFound' ("The user name could not be found").
 
T

Thomas

thanks a lot, i´ve found the problem

msgbuf has to be the message... i was a little bit lazy in reading:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top