I decided to test question 2 by writing a simple program and these are the results:
On Win32 struct MSG
is 28 bytes and Message
is 20 bytes. Message
adds a field result
which is an IntPtr
, but lacks the time
and POINT
fields.
Using either struct MSG
or Message
with Marshal.StructureToPtr
+ zeroing out the remaining 8 bytes yields the same results. Both have same hwnd
, message
, wparam
and lparam
and for both the rest of the properties are 0.
The conclusion is that Message
does contain the first few members in the correct order, but since it is too small it is not safe to directly be used. However, the lack of crashing of a test program using the naive implementation seems to suggest that TranslateMessage
does not look at the missing fields, but this is conjecture.
As for question 1, it seems to work without issue: TranslateMessage
generates the correct WM_CHAR
messages. I assume as long as the application doesn't use the time
or POINT
fields it should work.