"Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote in message <news:3d778b94$1@>...

> I have been writing a little utility which sends and catches those pop up
> boxes you get in Win NT/2000 when some NET SENDs you. (The latter is done
> by periodically doing FindWindowEx() where class is "#32770" and window text
> is "Messenger Service ", and retrieving the text in the static control.).
> To send messages, I use NetMessageBufferSend(). This works fine, but only
> if I use vbNullString for servername and fromname. I would ideally like to
> be able to a more useful name than my machine, but if I set fromname to
> anything else, the function fails. Does anyone know how to do this?
> I have looked on the internet for clues on how to do this, but it seems that
> the same solution is being used by everyone - and it doesn't seem to work.
> For some reason, the Declare is:
> Private Declare Function NetMessageBufferSend Lib "NetApi32.dll" ( _
> Byval servername As String, _
> Byval msgname As String, _
> ByVal fromname As String, _
> ByVal buf As String _
> ByVal buflen As Long _
> ) As Long
> And when called, all the string parameters are passed as
> StrConv(stringvalue, vbUnicode).

I take it NetMessageBufferSend expects Unicode strings? The StrConv
must be to defeat VB's automatic Unicode-to-ASCII conversions when
calling into "ordinary" DLLs. I usually wrap such things in a small
Sub or Function which passes strings using ByVal StrPtr(mystring) to
ByRef As Any parameters and then attempts to convert Err.LastDllError
codes to VB-ish errors. Who in their right mind wants to deal with
the equivalent of K&R C's errno all the time?

> After messing unsuccessfully with this for a couple of hours, I declared it
> in a typelib, and it worked fine.

Which worked fine, calling the typelib NetMessageBufferSend with or
without overriding servername and fromname?

Joe Foster <mailto:jlfoster%40znet.com> Got Thetans? <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!