Hack Forums
[.NET] [VB.NET]Windows Live Messenger "Now Playing" - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [VB.NET]Windows Live Messenger "Now Playing" (/showthread.php?tid=397053)



[VB.NET]Windows Live Messenger "Now Playing" - codepoet - May 1, 2010

originally posted on dotnet-snippets.com

Description:

This class allows you to send a string to Windows Live Messenger to let other users see what you are just listening, like Windows Media Player.

Code
Imports System.Runtime.InteropServices

Public Class MSNStatusMessage
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
        ByVal hWnd1 As Integer, _
        ByVal hWnd2 As Integer, _
        ByVal lpsz1 As String, _
        ByVal lpsz2 As String) _
    As Integer

    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
        ByVal Hwnd As Integer, _
        ByVal wMsg As Integer, _
        ByVal wParam As Integer, _
        ByVal lParam As Integer) _
    As Integer

    Private Const WM_COPYDATA As Short = 74

    Private Structure COPYDATASTRUCT
        Public dwData As Integer
        Public cbData As Integer
        Public lpData As Integer
    End Structure

    Public Enum EnumCategory As Integer
        Music = 0
        Games = 1
        Office = 2
    End Enum

    Public Shared Sub SendStatusMessage(ByVal Enable As Boolean, ByVal Category As EnumCategory, Optional ByVal Message As String = "")
        Dim Data As COPYDATASTRUCT
        Dim Buffer As String = "\0" & Category.ToString + "\0" & IIf(Enable, "1", "0") & "\0{0}\0" & Message & "\0\0\0\0" & Chr(0) & ""
        Dim Handle As Integer = 0

        Data.dwData = 1351
        Data.lpData = VarPtr(Buffer)
        Data.cbData = Buffer.Length * 2

        Handle = FindWindowEx(0, Handle, "MsnMsgrUIManager", Nothing)

        If Handle > 0 Then
            SendMessage(Handle, WM_COPYDATA, 0, VarPtr(Data))
        End If
    End Sub

    Private Shared Function VarPtr(ByVal e As Object) As Integer
        Dim GC As GCHandle = GCHandle.Alloc(e, GCHandleType.Pinned)
        Dim GC2 As Integer = GC.AddrOfPinnedObject.ToInt32
        GC.Free()
        Return GC2
    End Function
End Class

If You Like this tutorial, please check out my other tutorials by clicking ==> H3R3


* - iRtehLeet™ - May 1, 2010

Usage:

Code
'Enum can show games icon, music icon etc
SendStatusMessage(True, EnumCategoryGames, "Whatever you want to write")

I think this could be used for spreading!


* - codepoet - May 2, 2010

that correct...

2short


* - Cunt - May 2, 2010

@ iRtehLeet it shud be
Code
SendStatusMessage(True, EnumCategory.Games, "Whatever you want to write")

there shud be a . i kno what you ment i gota ya but some newbs might not :)


* - Byte - May 2, 2010

Seems really good, might use it.

Thanks


* - Cunt - May 2, 2010

for people who are lazy - :

http://www.multiupload.com/5FLOYBXZ5R

i put it together so you can play around :) has RADIO BUTTONS ZOMG :o
also crow ima + rep u for ur posting rage


* - Byte - May 2, 2010

http://dotnet-snippets.com/dns/windows-live-messenger-now-playing-SID590.aspx


O.o