|
-
Nov 18th, 1999, 10:09 PM
#1
Thread Starter
Junior Member
I'm attempting to make a VB function for NetMessageBufferSend in netapi32.dll. So far, I've come up with:
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
From the API doc's it is:
NET_API_STATUS NetMessageBufferSend(
LPWSTR servername,
LPWSTR msgname,
LPWSTR fromname,
LPBYTE buf,
DWORD buflen
);
Everytime I call the function though it returns an error 53 - which from doc's that I've been able to find is "Network path not found". I think it has something to do with the Unicode translations and all. Does anyone have a VB function for this API before I spend the next 4 hours playing around with it?
Thanks!
-
Nov 18th, 1999, 10:30 PM
#2
Guru
It would be easier (correction: possible) to solve this problem if you told us how you're calling this function. [lRet = NetMessageBufferSend(???)]
------------------
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
AIM: RYoni69
-
Nov 18th, 1999, 10:36 PM
#3
Thread Starter
Junior Member
lTemp = NetMessageBufferSend("FRUNDATZ", "WEBT", "FRUNDATZ", "Hello there", Len("Hello there"))
So, I'm attempting to send a message from the system FRUNDATZ (first parameter) to the system WEBT, coming from FRUNDATZ with the message "Hello there".
Thanks again!
-
Nov 18th, 1999, 10:48 PM
#4
Guru
I'm not sure (never used this API) but try this:
lTemp = NetMessageBufferSend("FRUNDATZ", "WEBT", "FRUNDATZ", ByVal "Hello there", ByVal Len("Hello there"))
-
Nov 18th, 1999, 11:03 PM
#5
Thread Starter
Junior Member
I gave it a whirl - unfortunately it didn't work. It's still complaining with an error 53... I think it has something to do with the way I'm passing it the strings for the machine names - it wants a LPWSTR variable and I think I'm just passing it an LPTSTR like in standard (non-Unicode API) calls. I think I have some example calls to some of the Unicode API calls - I'm going to look them up and see if I can translate them.
Thanks!
-
Nov 18th, 1999, 11:10 PM
#6
Guru
No, that's not it... The API is expecting the VB-style strings... Still, try this, it might work:
Dim sName As String, sMsg As String, sBuf As String, lLen As Long, lTemp As Long
sName = StrConv("FRUNDATZ", vbFromUnicode)
sMsg = StrConv("WEBT", vbFromUnicode)
sBuf = "Hello, world!"
lLen = LenB(sBuf)
lTemp = NetMessageBufferSend(sName, sMsg, sName, ByVal sBuf, ByVal lLen)
If that doesn't work, try changing both vbFromUnicode to vbUnicode.
------------------
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
AIM: RYoni69
-
Nov 18th, 1999, 11:38 PM
#7
Thread Starter
Junior Member
That worked! I have to say that you are the man! It worked changing the vbFromUnicode to vbUnicode. Also, the message was showing up as just "?????!" no matter what was in there so I did a StrConv to vbUnicode on that as well and the messages worked then.
Once again, thanks very much!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|