Results 1 to 7 of 7

Thread: NetAPI - How to make VB function for NetMessageBufferSend

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    Souderton, PA, USA
    Posts
    19

    Post

    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!

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    Souderton, PA, USA
    Posts
    19

    Post

    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!

  4. #4
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    I'm not sure (never used this API) but try this:

    lTemp = NetMessageBufferSend("FRUNDATZ", "WEBT", "FRUNDATZ", ByVal "Hello there", ByVal Len("Hello there"))

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    Souderton, PA, USA
    Posts
    19

    Post


    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!

  6. #6
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    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

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    Souderton, PA, USA
    Posts
    19

    Post


    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
  •  



Click Here to Expand Forum to Full Width