NetMessageBufferSend - XP - Help!!!

J

Jared

Hello all,
I'm having problems with the NetMessageBufferSend call. First, I'll
explain what is happening and then I will post some code. I have written a
net send interface a while back and everything was working fine, recently I
noticed a lot of failures when I try to send a message.

I've also noticed that most of the "problem" computers are running Windows
XP.
I receive error message 2273 (NERR_NameNotFound); this is funny to be
because the output of "net name" shows my computer name as being in the
local name table.
To fix this I tried calling the NetMessageNameAdd function, but, I receive
2276 (NERR_AlreadyExists). I checked the dependencies of the Messenger
service, and made sure everything was started.

I can recreate the problem on my home computer (XP Pro), I also have a
virtual server on my pc (2000 AS) in which the program works fine. I've
spent the entire day trying to find an answer for this and I came up with
nothing. I even registered the Win2000 version of netapi32.dll on my
computer using a different name with the exact same results. I can however
bring up a command window and net send my self without a problem. I am not
having very much luck here!

A second question, how do you send a message to a specific user account
using vb.net? I haven't been able to find this answer either. Any help would
be greatly appreciated.

TIA,
Jared

Here are the calls:


Private Structure NetMessageData
Dim sServerName As String
Dim sSendTo As String
Dim sSendFrom As String
Dim sMessage As String
End Structure

'START HERE
Public Function SendMessageToComputer() As Boolean
Dim sMessage As String = Space$(MESSAGE_SIZE * 2) 'MESSAGE_SIZE = 1024
sMessage = Me.Message
Dim success As Long
Dim SingleMessage As New NetMessageData

With SingleMessage
.sMessage = Me.Message
.sSendFrom = Me.SendFrom
.sSendTo = Me.SendTo
If Not .sServerName = Nothing Then .sServerName = Me.Server
End With

success = Me.NetSendMessage(SingleMessage)

Select Case success
Case ERROR_ACCESS_DENIED
Return False
Case ERROR_BAD_NETPATH
Return False
Case ERROR_INVALID_PARAMETER
Return False
Case ERROR_NOT_SUPPORTED
Return False
Case ERROR_INVALID_NAME
Return False
Case NERR_BASE
Return False
Case NERR_SUCCESS
Return True
Case NERR_NETWORK_ERROR
Return False
Case NERR_NAME_NOT_FOUND
Return False
Case NERR_USE_NOT_FOUND
Return False
End Select
End Function

Private Function NetSendMessage(ByVal msgData As NetMessageData) As Long
Dim sMessage As String
Dim success As Long
With msgData
If Len(.sMessage) > 0 And Len(.sSendTo) > 0 Then
sMessage = Space$(MESSAGE_SIZE * 2)
sMessage = .sMessage & sMessage
success = Win32.NetMessageBufferSend(.sServerName, .sSendTo,
..sSendFrom, sMessage, MESSAGE_SIZE * 2)
End If
End With
Return success
End Function

Friend Class Win32
<DllImport("NetAPI32.dll", CharSet:=CharSet.Unicode)> _
Public Shared Function NetMessageBufferSend(ByVal lpServerName As
String, _
ByVal lpMsgName As String, ByVal lpFromName As String, _
ByVal lpBuf As String, ByVal lnBufLen As Int32) As Int32
End Function

'Other DllImports...

End Class
 
O

One Handed Man [ OHM# ]

Just a thought, ( Not a cure ), have you tried adding the name of the
computer to a LMHOSTS file to remove the need for resolution of the machine
?

Regards - OHM
Hello all,
I'm having problems with the NetMessageBufferSend call. First,
I'll explain what is happening and then I will post some code. I have
written a net send interface a while back and everything was working
fine, recently I noticed a lot of failures when I try to send a
message.

I've also noticed that most of the "problem" computers are running
Windows XP.
I receive error message 2273 (NERR_NameNotFound); this is funny to be
because the output of "net name" shows my computer name as being in
the local name table.
To fix this I tried calling the NetMessageNameAdd function, but, I
receive 2276 (NERR_AlreadyExists). I checked the dependencies of the
Messenger service, and made sure everything was started.

I can recreate the problem on my home computer (XP Pro), I also have
a virtual server on my pc (2000 AS) in which the program works fine.
I've spent the entire day trying to find an answer for this and I
came up with nothing. I even registered the Win2000 version of
netapi32.dll on my computer using a different name with the exact
same results. I can however bring up a command window and net send my
self without a problem. I am not having very much luck here!

A second question, how do you send a message to a specific user
account using vb.net? I haven't been able to find this answer either.
Any help would be greatly appreciated.

TIA,
Jared

Here are the calls:


Private Structure NetMessageData
Dim sServerName As String
Dim sSendTo As String
Dim sSendFrom As String
Dim sMessage As String
End Structure

'START HERE
Public Function SendMessageToComputer() As Boolean
Dim sMessage As String = Space$(MESSAGE_SIZE * 2) 'MESSAGE_SIZE
= 1024 sMessage = Me.Message
Dim success As Long
Dim SingleMessage As New NetMessageData

With SingleMessage
.sMessage = Me.Message
.sSendFrom = Me.SendFrom
.sSendTo = Me.SendTo
If Not .sServerName = Nothing Then .sServerName = Me.Server
End With

success = Me.NetSendMessage(SingleMessage)

Select Case success
Case ERROR_ACCESS_DENIED
Return False
Case ERROR_BAD_NETPATH
Return False
Case ERROR_INVALID_PARAMETER
Return False
Case ERROR_NOT_SUPPORTED
Return False
Case ERROR_INVALID_NAME
Return False
Case NERR_BASE
Return False
Case NERR_SUCCESS
Return True
Case NERR_NETWORK_ERROR
Return False
Case NERR_NAME_NOT_FOUND
Return False
Case NERR_USE_NOT_FOUND
Return False
End Select
End Function

Private Function NetSendMessage(ByVal msgData As NetMessageData) As
Long Dim sMessage As String
Dim success As Long
With msgData
If Len(.sMessage) > 0 And Len(.sSendTo) > 0 Then
sMessage = Space$(MESSAGE_SIZE * 2)
sMessage = .sMessage & sMessage
success = Win32.NetMessageBufferSend(.sServerName,
.sSendTo, .sSendFrom, sMessage, MESSAGE_SIZE * 2)
End If
End With
Return success
End Function

Friend Class Win32
<DllImport("NetAPI32.dll", CharSet:=CharSet.Unicode)> _
Public Shared Function NetMessageBufferSend(ByVal lpServerName As
String, _
ByVal lpMsgName As String, ByVal lpFromName As String, _
ByVal lpBuf As String, ByVal lnBufLen As Int32) As Int32
End Function

'Other DllImports...

End Class

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
J

Jared

It didn't work, I made the entry in the LMHOSTS file, made sure my network
adapters would use the file, restarted and I have the same results,
NERR_NameNotFound? Any more suggestions?

Thanks OHM for at least looking at my post, it gets so frustrating when you
don't see any comments, makes you think you are wasting your time.
Jared
 
O

One Handed Man [ OHM# ]

If its not resolution then maybe you have made some small error in the host
name?. Alternatively, what about using the IP number rather than the
Hostname.

If the hosts your trying to connect to is not on your network subnet, maybe
you have a routing issue. Wins maybe be able to braodcast the members list
on your subnet but your not able to get to it ?

Dunno, just throwing up ideas

OHM



It didn't work, I made the entry in the LMHOSTS file, made sure my
network adapters would use the file, restarted and I have the same
results, NERR_NameNotFound? Any more suggestions?

Thanks OHM for at least looking at my post, it gets so frustrating
when you don't see any comments, makes you think you are wasting your
time.
Jared

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
J

Jared

I thought of that too, I am still having promlems on my local machine as
well. I tried converting the machnine name to its ip address using the
system.net.dns.gethostbyname (going off memory, bear with me I'm still
fairly new to this). It correctly resolves my IP address and I still don't
get the messgae. On my virtual machine it works like a champ. I don't know
if this is a problem with the netapi32.dll that is supplied with XP (version
2600.x.x.whatever vs 2195.x.x..whatever). Have you been able to make it work
on an xp pro machine? I think I supplied enough code to just copy and paste
most of it.

Thanks again for the help OHM
Jared
 
O

One Handed Man [ OHM# ]

Sorry, I dont have an XP machine here to test it with. I dont think I can
help more at this point. Sorry, if your still having this problem post
Christmas then I will be able to test it on an XP machine then.


Regards - OHM
I thought of that too, I am still having promlems on my local machine
as well. I tried converting the machnine name to its ip address using
the system.net.dns.gethostbyname (going off memory, bear with me I'm
still fairly new to this). It correctly resolves my IP address and I
still don't get the messgae. On my virtual machine it works like a
champ. I don't know if this is a problem with the netapi32.dll that
is supplied with XP (version 2600.x.x.whatever vs
2195.x.x..whatever). Have you been able to make it work on an xp pro
machine? I think I supplied enough code to just copy and paste most
of it.

Thanks again for the help OHM
Jared

One Handed Man said:
If its not resolution then maybe you have made some small error in
the host name?. Alternatively, what about using the IP number rather
than the Hostname.

If the hosts your trying to connect to is not on your network
subnet, maybe you have a routing issue. Wins maybe be able to
braodcast the members list on your subnet but your not able to get
to it ?

Dunno, just throwing up ideas

OHM



It didn't work, I made the entry in the LMHOSTS file, made sure my
network adapters would use the file, restarted and I have the same
results, NERR_NameNotFound? Any more suggestions?

Thanks OHM for at least looking at my post, it gets so frustrating
when you don't see any comments, makes you think you are wasting
your time.
Jared


"One Handed Man [ OHM# ]" <OneHandedMan{at}BTInternet{dot}com> wrote
in message Just a thought, ( Not a cure ), have you tried adding the name of
the computer to a LMHOSTS file to remove the need for resolution
of the machine ?

Regards - OHM

Jared wrote:
Hello all,
I'm having problems with the NetMessageBufferSend call. First,
I'll explain what is happening and then I will post some code. I
have written a net send interface a while back and everything was
working fine, recently I noticed a lot of failures when I try to
send a message.

I've also noticed that most of the "problem" computers are running
Windows XP.
I receive error message 2273 (NERR_NameNotFound); this is funny to
be because the output of "net name" shows my computer name as
being in the local name table.
To fix this I tried calling the NetMessageNameAdd function, but, I
receive 2276 (NERR_AlreadyExists). I checked the dependencies of
the Messenger service, and made sure everything was started.

I can recreate the problem on my home computer (XP Pro), I also
have a virtual server on my pc (2000 AS) in which the program
works fine. I've spent the entire day trying to find an answer
for this and I came up with nothing. I even registered the
Win2000 version of netapi32.dll on my computer using a different
name with the exact same results. I can however bring up a
command window and net send my self without a problem. I am not
having very much luck here!

A second question, how do you send a message to a specific user
account using vb.net? I haven't been able to find this answer
either. Any help would be greatly appreciated.

TIA,
Jared

Here are the calls:


Private Structure NetMessageData
Dim sServerName As String
Dim sSendTo As String
Dim sSendFrom As String
Dim sMessage As String
End Structure

'START HERE
Public Function SendMessageToComputer() As Boolean
Dim sMessage As String = Space$(MESSAGE_SIZE * 2)
'MESSAGE_SIZE = 1024 sMessage = Me.Message
Dim success As Long
Dim SingleMessage As New NetMessageData

With SingleMessage
.sMessage = Me.Message
.sSendFrom = Me.SendFrom
.sSendTo = Me.SendTo
If Not .sServerName = Nothing Then .sServerName =
Me.Server End With

success = Me.NetSendMessage(SingleMessage)

Select Case success
Case ERROR_ACCESS_DENIED
Return False
Case ERROR_BAD_NETPATH
Return False
Case ERROR_INVALID_PARAMETER
Return False
Case ERROR_NOT_SUPPORTED
Return False
Case ERROR_INVALID_NAME
Return False
Case NERR_BASE
Return False
Case NERR_SUCCESS
Return True
Case NERR_NETWORK_ERROR
Return False
Case NERR_NAME_NOT_FOUND
Return False
Case NERR_USE_NOT_FOUND
Return False
End Select
End Function

Private Function NetSendMessage(ByVal msgData As NetMessageData)
As Long Dim sMessage As String
Dim success As Long
With msgData
If Len(.sMessage) > 0 And Len(.sSendTo) > 0 Then
sMessage = Space$(MESSAGE_SIZE * 2)
sMessage = .sMessage & sMessage
success = Win32.NetMessageBufferSend(.sServerName,
.sSendTo, .sSendFrom, sMessage, MESSAGE_SIZE * 2)
End If
End With
Return success
End Function

Friend Class Win32
<DllImport("NetAPI32.dll", CharSet:=CharSet.Unicode)> _
Public Shared Function NetMessageBufferSend(ByVal lpServerName
As String, _
ByVal lpMsgName As String, ByVal lpFromName As String, _
ByVal lpBuf As String, ByVal lnBufLen As Int32) As Int32
End Function

'Other DllImports...

End Class

Regards - OHM# OneHandedMan{at}BTInternet{dot}com

Regards - OHM# OneHandedMan{at}BTInternet{dot}com

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
J

Jared

Okay,
Thanks for your help, I figured I wouldn't have much luck with this. I
don't think its coded wrong because it works on 2000 machines. I think that
microsoft changed the way xp handles messenger service calls or something
like that. I think it has more to do with XP than NetMessageBufferSend.

I will assume this issued can't be solved here and will discontinue to look
for responses.
If anyone knows of a solution please post and send me a courtsey e-mail
using.

Thanks,
Jared

One Handed Man said:
Sorry, I dont have an XP machine here to test it with. I dont think I can
help more at this point. Sorry, if your still having this problem post
Christmas then I will be able to test it on an XP machine then.


Regards - OHM
I thought of that too, I am still having promlems on my local machine
as well. I tried converting the machnine name to its ip address using
the system.net.dns.gethostbyname (going off memory, bear with me I'm
still fairly new to this). It correctly resolves my IP address and I
still don't get the messgae. On my virtual machine it works like a
champ. I don't know if this is a problem with the netapi32.dll that
is supplied with XP (version 2600.x.x.whatever vs
2195.x.x..whatever). Have you been able to make it work on an xp pro
machine? I think I supplied enough code to just copy and paste most
of it.

Thanks again for the help OHM
Jared

One Handed Man said:
If its not resolution then maybe you have made some small error in
the host name?. Alternatively, what about using the IP number rather
than the Hostname.

If the hosts your trying to connect to is not on your network
subnet, maybe you have a routing issue. Wins maybe be able to
braodcast the members list on your subnet but your not able to get
to it ?

Dunno, just throwing up ideas

OHM




Jared wrote:
It didn't work, I made the entry in the LMHOSTS file, made sure my
network adapters would use the file, restarted and I have the same
results, NERR_NameNotFound? Any more suggestions?

Thanks OHM for at least looking at my post, it gets so frustrating
when you don't see any comments, makes you think you are wasting
your time.
Jared


"One Handed Man [ OHM# ]" <OneHandedMan{at}BTInternet{dot}com> wrote
in message Just a thought, ( Not a cure ), have you tried adding the name of
the computer to a LMHOSTS file to remove the need for resolution
of the machine ?

Regards - OHM

Jared wrote:
Hello all,
I'm having problems with the NetMessageBufferSend call. First,
I'll explain what is happening and then I will post some code. I
have written a net send interface a while back and everything was
working fine, recently I noticed a lot of failures when I try to
send a message.

I've also noticed that most of the "problem" computers are running
Windows XP.
I receive error message 2273 (NERR_NameNotFound); this is funny to
be because the output of "net name" shows my computer name as
being in the local name table.
To fix this I tried calling the NetMessageNameAdd function, but, I
receive 2276 (NERR_AlreadyExists). I checked the dependencies of
the Messenger service, and made sure everything was started.

I can recreate the problem on my home computer (XP Pro), I also
have a virtual server on my pc (2000 AS) in which the program
works fine. I've spent the entire day trying to find an answer
for this and I came up with nothing. I even registered the
Win2000 version of netapi32.dll on my computer using a different
name with the exact same results. I can however bring up a
command window and net send my self without a problem. I am not
having very much luck here!

A second question, how do you send a message to a specific user
account using vb.net? I haven't been able to find this answer
either. Any help would be greatly appreciated.

TIA,
Jared

Here are the calls:


Private Structure NetMessageData
Dim sServerName As String
Dim sSendTo As String
Dim sSendFrom As String
Dim sMessage As String
End Structure

'START HERE
Public Function SendMessageToComputer() As Boolean
Dim sMessage As String = Space$(MESSAGE_SIZE * 2)
'MESSAGE_SIZE = 1024 sMessage = Me.Message
Dim success As Long
Dim SingleMessage As New NetMessageData

With SingleMessage
.sMessage = Me.Message
.sSendFrom = Me.SendFrom
.sSendTo = Me.SendTo
If Not .sServerName = Nothing Then .sServerName =
Me.Server End With

success = Me.NetSendMessage(SingleMessage)

Select Case success
Case ERROR_ACCESS_DENIED
Return False
Case ERROR_BAD_NETPATH
Return False
Case ERROR_INVALID_PARAMETER
Return False
Case ERROR_NOT_SUPPORTED
Return False
Case ERROR_INVALID_NAME
Return False
Case NERR_BASE
Return False
Case NERR_SUCCESS
Return True
Case NERR_NETWORK_ERROR
Return False
Case NERR_NAME_NOT_FOUND
Return False
Case NERR_USE_NOT_FOUND
Return False
End Select
End Function

Private Function NetSendMessage(ByVal msgData As NetMessageData)
As Long Dim sMessage As String
Dim success As Long
With msgData
If Len(.sMessage) > 0 And Len(.sSendTo) > 0 Then
sMessage = Space$(MESSAGE_SIZE * 2)
sMessage = .sMessage & sMessage
success = Win32.NetMessageBufferSend(.sServerName,
.sSendTo, .sSendFrom, sMessage, MESSAGE_SIZE * 2)
End If
End With
Return success
End Function

Friend Class Win32
<DllImport("NetAPI32.dll", CharSet:=CharSet.Unicode)> _
Public Shared Function NetMessageBufferSend(ByVal lpServerName
As String, _
ByVal lpMsgName As String, ByVal lpFromName As String, _
ByVal lpBuf As String, ByVal lnBufLen As Int32) As Int32
End Function

'Other DllImports...

End Class

Regards - OHM# OneHandedMan{at}BTInternet{dot}com

Regards - OHM# OneHandedMan{at}BTInternet{dot}com

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 

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