?
Solved

Messenger service popup in vb.net not behaving as it should...

Posted on 2003-03-31
5
Medium Priority
?
257 Views
Last Modified: 2010-05-01
Using NetMessageBufferSend function, the messenger pop up shows funny symbols after the message text eg: !!!???!!@@@ and so on. How can I get rid of this?

The code is:

Public Declare Unicode Function NetMessageBufferSend Lib "netapi32" _
            (ByVal servername As String, _
            ByVal msgname As String, _
            ByVal fromname As String, _
            ByVal msgbuf As String, _
            ByRef msgbuflen As Long) As Long

I know that msgbuf should be in byte. But then how do I change the input message to byte in vb.net?
Can anyone help? Thanks...
0
Comment
Question by:krchome
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 8238332
Try this

Try this


Option Explicit

Private Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" (yServer As Any, yToName As Byte, yFromName As Any, yMsg As Byte, ByVal lSize As Long) As Long

Private Sub Command1_Click()
   Dim lRet As Long
   
   lRet = BroadcastMessage("TO_NODE_NAME", "FROM_NODE_NAME", "YOUR_MESSAGE")
   
   '----- Traitement postirieur de l'envoi
  Select Case lRet
     Case 0
        Debug.Print "  MESSAGE SUCCESSFULLY SENT !"
     Case 53
        Debug.Print "  ERROR : BAD NAME !   ( FROM )"
     Case 123
        Debug.Print "  ERROR : EMPTY NAME !"
     Case 2273
        Debug.Print "  ERROR : BAD NAME !   ( TO )"
  End Select
End Sub

Private Function BroadcastMessage(pDst As String, pExp As String, pMsg As String) As Long
 
  '----- Variables
  Dim lDstName() As Byte
  Dim lExpName() As Byte
  Dim lMsg() As Byte
  Dim lRet As Long
 
  '----- Affectation des valeurs
  lDstName = pDst & vbNullChar
  lExpName = pExp & vbNullChar
  lMsg = pMsg & vbNullChar
 
  '----- Envoi du message
  lRet = NetMessageBufferSend(lExpName(0), lDstName(0), lExpName(0), lMsg(0), UBound(lMsg))
  BroadcastMessage = lRet
End Function
0
 

Author Comment

by:krchome
ID: 8241608
Sorry the code you have sent works in vb6 but not in vb.net. I have got the answer myself and now I am sending you the translated code which will make your code work in vb.net. It might be useful to you if you migrate to vb.net. I am already using NetMessageBufferSend in vb6, so I was aware of the code that you have sent. Thanks anyway!! Here goes...

Private Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" (ByRef yServer As Byte, ByRef yToName As Byte, ByRef yFromName As Byte, ByRef yMsg As Byte, ByVal lSize As Integer) As Integer
     
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
Dim lRet As Integer
         
lRet = BroadcastMessage("TO_NODE_NAME", "FROM_NODE_NAME", "YOUR_MESSAGE")
         
'----- Traitement postirieur de l'envoi
Select Case lRet
Case 0
System.Diagnostics.Debug.WriteLine("  MESSAGE SUCCESSFULLY SENT !")
Case 53
System.Diagnostics.Debug.WriteLine("  ERROR : BAD NAME !   ( FROM )")
Case 123
System.Diagnostics.Debug.WriteLine("  ERROR : EMPTY NAME !")
Case 2273
System.Diagnostics.Debug.WriteLine("  ERROR : BAD NAME !   ( TO )")
End Select
End Sub
     
Private Function BroadcastMessage(ByRef pDst As String, ByRef pExp As String, ByRef pMsg As String) As Integer
         
'----- Variables
Dim lDstName() As Byte
Dim lExpName() As Byte
Dim lMsg() As Byte
Dim lRet As Integer
         
'----- Affectation des valeurs
lDstName = System.Text.UnicodeEncoding.Unicode.GetBytes(pDst & vbNullChar)

lExpName = System.Text.UnicodeEncoding.Unicode.GetBytes(pExp & vbNullChar)
         
lMsg = System.Text.UnicodeEncoding.Unicode.GetBytes(pMsg & vbNullChar)
         
'----- Envoi du message
lRet = NetMessageBufferSend(lExpName(0), lDstName(0), lExpName(0), lMsg(0), UBound(lMsg))
BroadcastMessage = lRet
End Function
0
 

Expert Comment

by:CleanupPing
ID: 8531279
Hi krchome,
This old question (QID 20568509) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 8966078
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ/Refund
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GrahamSkan
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
ID: 9039701
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question