How to get the string passed by SendMessage?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

1. I am using SendMessage (HWND_BROADCAST, WM_FONTCHANGE, 0,
(LPARAM)pFileName); in C++ side
2. In WndProc, I wanted to get the fileName from m.lparam, which is a
IntPtr. How can I convert it to a string in C#

Thanks.
 
Gary,

You can pass this to the IntPtr to the static PtrToStringAnsi or
PtrToStringUni methods on the Marshal class depending on what version of
SendMessage was called (SendMessageA, or SendMessageW).

Hope this helps.
 
Gary said:
1. I am using SendMessage (HWND_BROADCAST, WM_FONTCHANGE, 0,
(LPARAM)pFileName); in C++ side
2. In WndProc, I wanted to get the fileName from m.lparam, which is a
IntPtr. How can I convert it to a string in C#

Thanks.

I'm not sure that pointer is valid in other applications/processes
(other than one that call SendMessage). Check WM_COPYDATA if you need IPC.

Regards,
Goran
 
Back
Top