- Bjarne Anker
- PowerBuilder
- Thursday, 25 January 2018 08:09 PM UTC
Hi.
Has anyone successfully managed to receive string data sent from a C# application using SendMessage?
We have a small starter program written in C# which is triggered from a website.
This starter program will do some small work and pass a string (perhaps XML) to a running PowerBuilder 2017 application (32-bit).
This is the C# code:
[DllImport("user32.dll", SetLastError = true, EntryPoint = "SendMessageA", CharSet = CharSet.Ansi)]
internal static extern Int32 SendMessageAnsiPtr(IntPtr hWnd, uint Msg, Int32 wParam, IntPtr lParam);
ptr = Marshal.StringToHGlobalAnsi("Hello World");
SendMessageAnsiPtr(proc.MainWindowHandle, 0x429, 11, ptr); //11 is the length of the string hardcoded for testing
Marshal.FreeHGlobal(ptr); //freee the memory to avoid memory leak
This triggers an event in PB mapped to the pbm_custom42 eventhandler.
It receives a pointer to the string, and I've tried this:
string ls_result
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.