M
michelqa
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/library/bb760720(VS.85).aspx
---------------------------------------------------------
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hwnd, int msg, IntPtr
wparam, IntPtr lparam);
//...
[StructLayout(LayoutKind.Sequential)]
public struct LITEM
{
uint mask;
int iLink;
uint state;
uint stateMask;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
string szID; //??? is it equivalent to WCHAR ?//
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
string szUrl; //??? is it equivalent to WCHAR ?//
}
LITEM MyLItem = new LITEM();
int MsgResult = SendMessage(Handle,LM_GETITEM,IntPtr.Zero,ref
MyLItem); //<----- ???????
I know the information in the struct must be set before calling
sendmessage...the 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/library/bb760720(VS.85).aspx
---------------------------------------------------------
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hwnd, int msg, IntPtr
wparam, IntPtr lparam);
//...
[StructLayout(LayoutKind.Sequential)]
public struct LITEM
{
uint mask;
int iLink;
uint state;
uint stateMask;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
string szID; //??? is it equivalent to WCHAR ?//
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
string szUrl; //??? is it equivalent to WCHAR ?//
}
LITEM MyLItem = new LITEM();
int MsgResult = SendMessage(Handle,LM_GETITEM,IntPtr.Zero,ref
MyLItem); //<----- ???????
I know the information in the struct must be set before calling
sendmessage...the 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...