Euh, c'est pour MSN 7 seulement? On est à la version 14 (2009) donc à moins que cette source fonctionne aussi avec les dernières versions (qui maintenant s'appellent Live Messenger), je ne vois pas trop l'intérêt de la source...
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
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
Public Function VarPtr(ByVal o As Object) As Integer
Dim GC As System.Runtime.InteropServices.GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(o, System.Runtime.InteropServices.GCHandleType.Pinned)
Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32
GC.Free()
Return ret
End Function
Private Structure COPYDATASTRUCT
Dim dwData As Integer
Dim cbData As Integer
Dim lpData As Integer
End Structure
Private Const WM_COPYDATA As Short = &H4AS
Public Sub SetMsgPerso(ByRef r_type As String, ByRef r_newMsg As String, Optional ByRef r_bShow As Boolean = True)
Dim udtData As COPYDATASTRUCT
Dim sBuffer As String
Dim hMSGRUI As Integer
'Total length can not be longer then 256 characters!
'Any longer will simply be ignored by Messenger.
'sBuffer = "\0Music\0" & System.Math.Abs(CInt(r_bShow)) & "\0" & r_sFormat & "\0" & r_sArtist & "\0" & r_sTitle & "\0" & r_sAlbum & "\0" & r_sWMContentID & "\0" & vbNullChar
sBuffer = "\0" & r_type & "\0" & System.Math.Abs(CInt(r_bShow)) & "\0" & r_newMsg & "\0" & "\0" & vbNullChar
Ok merci beaucoup pour ton code :D
Première différence, je ne sais pas si c'est ca : udtData.dwData &H547S, et idem pour le WM_COPYDATA &H4AS (et j'avais en VB &H547 et &H4A) mais je n'ai pas mon code ici pour tester et comparer directement.
Je n'avais jamais vu ce S ^^
j'utilise cette méthode en Vb.Net dans une source ( http://yaurthek.free.fr/?page=dev&id=4 )
voila le code copié collé si ça peut t'aider :
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
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
Public Function VarPtr(ByVal o As Object) As Integer
Dim GC As System.Runtime.InteropServices.GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(o, System.Runtime.InteropServices.GCHandleType.Pinned)
Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32
GC.Free()
Return ret
End Function
Private Structure COPYDATASTRUCT
Dim dwData As Integer
Dim cbData As Integer
Dim lpData As Integer
End Structure
Private Const WM_COPYDATA As Short = &H4AS
Public Sub SetMsgPerso(ByRef r_type As String, ByRef r_newMsg As String, Optional ByRef r_bShow As Boolean = True)
Dim udtData As COPYDATASTRUCT
Dim sBuffer As String
Dim hMSGRUI As Integer
'Total length can not be longer then 256 characters!
'Any longer will simply be ignored by Messenger.
'sBuffer = "\0Music\0" & System.Math.Abs(CInt(r_bShow)) & "\0" & r_sFormat & "\0" & r_sArtist & "\0" & r_sTitle & "\0" & r_sAlbum & "\0" & r_sWMContentID & "\0" & vbNullChar
sBuffer = "\0" & r_type & "\0" & System.Math.Abs(CInt(r_bShow)) & "\0" & r_newMsg & "\0" & "\0" & vbNullChar
udtData.dwData = &H547S
udtData.lpData = VarPtr(sBuffer)
udtData.cbData = Len(sBuffer) * 2
Do
hMSGRUI = FindWindowEx(0, hMSGRUI, "MsnMsgrUIManager", vbNullString)
If (hMSGRUI > 0) Then
Call SendMessage(hMSGRUI, WM_COPYDATA, 0, VarPtr(udtData))
End If
Loop Until (hMSGRUI = 0)
End Sub
Première différence, je ne sais pas si c'est ca : udtData.dwData &H547S, et idem pour le WM_COPYDATA &H4AS (et j'avais en VB &H547 et &H4A) mais je n'ai pas mon code ici pour tester et comparer directement.
Je n'avais jamais vu ce S ^^