MSN "Listening To"

Joined
Feb 15, 2008
Messages
11
Programming Experience
1-3
I am currently developing an Audio Player to interact with another program.

Some people i know said it would be great to get the player to send the Track name etc to MSN Listening to.

now i want to create this as a DLL file, the reason why a DLL file is i find it easier to use for other application that i can use it on, so all i need to do is type something like so:-

MSNControl.Send(Artistname & " - " SongTitle)

now i am not asking for someone to give me the code because that way i will not learn how to do it for myself.

all i am asking is some pointers, things to look at, components to use or maybe SDK to install.

any help in this way will be gratly appreciated, Thanks
 
ah there is, all i needed to do was add the COM reference "Messenger API" but i am still looking at things.

Even tho the API is there, i am still confused with it
 
Last edited:
RE: MSN "Listening To", DLL Completed

after HOURS of working on this thing i have finally got it

There may be some issues with earlier versions of MSN Messenger as in it will not send the information.
I do know it works on Live Messenger 2008 (Build 8.5.13002.1018), thats what i am currently using.



== How to Use ==
1] Make sure on MSN that the "What I'm Listening to" is activated

2] you need to add the dll MSNPlug as a refference and browse for the file

3] you need to Declare it like so
VB.NET:
Dim MSN As New MSNPlug.ChangeText
or you can make it public or what ever you feel like

4] All you need to do is, for example on a button click event
VB.NET:
    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) _
                              Handles Button1.Click

        'Displays song info to Live Messenger

        Dim c As String = TextBox1.Text
        Dim b As String = TextBox2.Text
        Dim a As String = a & " - " & b

        '' MSN.Send([Display name on MSN], [Artist Name], [Track Name])
        MSN.Send(a, b, c)

    End Sub

5] To stop it showing on MSN use this code, for example if the form Closes

VB.NET:
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As _
                                  System.Windows.Forms.FormClosingEventArgs) _ 
                                  Handles Me.FormClosing

        MSN.Send("", "", "", False)

    End Sub

This is written in .NET Framework 3.5 using VS2008

If you want the original source then please let me know on this thread and i will post it.

I hope you find some use for this, any comments or suggestions to develop this further then please let me know.

I will not develop any further than to change the "What I'm Listening To" feature.

I am aware that you can change the icon to a Games and Office image to. Tomorrow or when i got time i will add that in and i will update you
 

Attachments

  • MSNPlug.zip
    6.4 KB · Views: 30
Last edited:
Update, Icon Change Added

Follow the steps above

but to use it

VB.NET:
'' MSN.Send([Display name on MSN], [Artist Name], [Track Name], [Icon])
'' Icon can = "Music" "Games" or "Office" that i know of
'' Icon is default to "Music" so you can leave that part out if you dont want to change it
MSN.Send("Artist - Track", "Artist", "Track", "Music")

stop it showing just use the following code

VB.NET:
MSN.Send("", "", "", , False)
 

Attachments

  • MSNPlug.zip
    6.4 KB · Views: 26
Last edited:
the source code basically, it sends a COPYDATASTRUCT to one of the Messenger windows:
VB.NET:
Imports system.Runtime.InteropServices
Class msnlistening
    Public Enum IconType
        Music
        Games
        Office
    End Enum

    
    Public Sub SetMessengerInfo(ByVal Artist As String, ByVal Album As String, ByVal Title As String, _
    Optional ByVal Icon As IconType = IconType.Music, _
    Optional ByVal WMContentID As String = vbNullString, _
    Optional ByVal Format As String = "{0} - {1}", _
    Optional ByVal Show As Boolean = True)
         
        Dim mess As String = String.Format("\0{0}\0{1}\0{2}\0{3}\0{4}\0{5}\0{6}\0" & vbNullChar, _
                                Icon.ToString, Math.Abs(CInt(Show)), Format, Artist, Title, Album, WMContentID)
        Dim lpMess As GCHandle = GCHandle.Alloc(mess, GCHandleType.Pinned)        
        Dim CD As Win32.COPYDATASTRUCT
        With CD
            .dwData = &H547
            .cbData = mess.Length * 2
            .lpData = lpMess.AddrOfPinnedObject
        End With
        Dim lpCD As GCHandle = GCHandle.Alloc(CD, GCHandleType.Pinned)
        Dim hMSGRUI As Integer
        Do
            hMSGRUI = Win32.FindWindowEx(0, hMSGRUI, "MsnMsgrUIManager", vbNullString)
            If (hMSGRUI > 0) Then
                Win32.SendMessage(hMSGRUI, Win32.WM_COPYDATA, 0, lpCD.AddrOfPinnedObject)
            End If
        Loop Until (hMSGRUI = 0)
        lpMess.Free()
        lpCD.Free()
    End Sub

End Class
Class Win32
    Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
  ByVal hwnd As Int32, _
  ByVal wMsg As Int32, _
  ByVal wParam As Int32, _
  ByVal lParam As IntPtr) As Int32

    Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
  ByVal lpClassName As String, _
  ByVal lpWindowName As String) As Int32

    Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" ( _
  ByVal hWnd1 As Int32, _
  ByVal hWnd2 As Int32, _
  ByVal lpsz1 As String, _
  ByVal lpsz2 As String) As Int32

    Public Structure COPYDATASTRUCT
        Public dwData As Int32
        Public cbData As Int32
        Public lpData As IntPtr
    End Structure

    Public Const WM_COPYDATA As Int32 = &H4A
End Class
 
Back
Top