Sending a string using SendMessage

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi there,

I'm trying to send a string to another window using SendMessage,
unfortunately I'm not having much luck turning the pointer back into a
string, this is what I'm currently doing,

'//Window sending the message
'//iData is a Char array
Dim pIPrData As IntPtr = Marshal.AllocHGlobal(iData.Length)
Call Marshal.Copy(iData, 0, pIPrData, iData.Length)
SendMessage(pIntHandle, iMsg, pIPrData, iData.Length)

'//In the WndProc method of the window recieving the message
Dim pChrMessage() As Char
Call Marshal.Copy(m.WParam, pChrMessage, 0, m.LParam.ToInt32)
Dim pStrMessage As New String(pChrMessage)
Call MessageBox.Show("Message = " & pStrMessage)

The length is being recieved correctly but I'm still not able to copy
the data into the char array. Any help on this would be greatly
appreciated!
 
I'm finally managing to get something from the pointer but it is not
correct. It looks like the wrong area of memory is being read. Presumably
you can actually send string in Windows Messages???

Nick.
 
Back
Top