Hi,
I need to call a lot of different native SendMessage to retreive
informations from non managed application.
Some win32 messages use struct pointer for lparam....how to create and
marshaling the struct to be able to use it in sendmessage...
Here is an example LM_GETITEM:
http://msdn.microsoft.com/en-us/libr...20(VS.85).aspx
---------------------------------------------------------
[DllImport("user 32.dll")]
public static extern IntPtr SendMessage(Int Ptr hwnd, int msg, IntPtr
wparam, IntPtr lparam);
//...
[StructLayout(La youtKind.Sequen tial)]
public struct LITEM
{
uint mask;
int iLink;
uint state;
uint stateMask;
[MarshalAs(Unman agedType.ByValT Str, SizeConst = 260)]
string szID; //??? is it equivalent to WCHAR ?//
[MarshalAs(Unman agedType.ByValT Str, SizeConst = 260)]
string szUrl; //??? is it equivalent to WCHAR ?//
}
LITEM MyLItem = new LITEM();
int MsgResult = SendMessage(Han dle,LM_GETITEM, IntPtr.Zero,ref
MyLItem); //<----- ???????
I know the information in the struct must be set before calling
sendmessage...t he code is just an incomplete example, but how to
create and marshaling a valid struct to call sendmessage in this
case? Is it possible when the Handle is in a different process??
Thanks for any help and example...
I need to call a lot of different native SendMessage to retreive
informations from non managed application.
Some win32 messages use struct pointer for lparam....how to create and
marshaling the struct to be able to use it in sendmessage...
Here is an example LM_GETITEM:
http://msdn.microsoft.com/en-us/libr...20(VS.85).aspx
---------------------------------------------------------
[DllImport("user 32.dll")]
public static extern IntPtr SendMessage(Int Ptr hwnd, int msg, IntPtr
wparam, IntPtr lparam);
//...
[StructLayout(La youtKind.Sequen tial)]
public struct LITEM
{
uint mask;
int iLink;
uint state;
uint stateMask;
[MarshalAs(Unman agedType.ByValT Str, SizeConst = 260)]
string szID; //??? is it equivalent to WCHAR ?//
[MarshalAs(Unman agedType.ByValT Str, SizeConst = 260)]
string szUrl; //??? is it equivalent to WCHAR ?//
}
LITEM MyLItem = new LITEM();
int MsgResult = SendMessage(Han dle,LM_GETITEM, IntPtr.Zero,ref
MyLItem); //<----- ???????
I know the information in the struct must be set before calling
sendmessage...t he code is just an incomplete example, but how to
create and marshaling a valid struct to call sendmessage in this
case? Is it possible when the Handle is in a different process??
Thanks for any help and example...
Comment