Discussion:
Send Message(string) c# exe to vc++ exe(unmanaged) using WindowsSendMessage
(too old to reply)
Mayur
2006-11-24 11:27:46 UTC
Permalink
I tried followinf but working fine fo int but how to do it for string using
user custome message

in c#
[DllImport("User32.dll")]

public static extern int FindWindow(string strClassName,string
strWindowName);

[DllImport("User32.dll")]

public static extern Int32 SendMessage(

int hWnd, // handle to destination window

int Msg, // message

int wParam, // first message parameter

[MarshalAs(UnmanagedType.LPStr)] string lParam);



public const int WM_APP = 0x8000;

public const int WM_DELETEALL =WM_APP + 0x100;

int wnd=FindWindow(null,"TestMfcSendMsgExe");

Form1.SendMessage(wnd,WM_DELETEALL,0,55);





and MFC Exe is like this

#define WM_DELETEALL WM_APP + 0x100

BEGIN_MESSAGE_MAP(CTestMfcSendMsgExeDlg, CDialog)

ON_MESSAGE (WM_DELETEALL, OnDeleteAll)


END_MESSAGE_MAP()

LRESULT CTestMfcSendMsgExeDlg::OnDeleteAll(WPARAM wParam, LPARAM lParam)

{

MessageBox("Hello","Mayur",MB_OK);

}

I am getting the message box after using SendMessage() in c# exe but i want
to send text(string ) information.

I need help..

Regards,

Mayur.
Vladimir Scherbina
2006-11-24 11:39:57 UTC
Permalink
Mayur,

You ask second time the question which is not corresponding to this
newsgroup. We discuss here the wininet technology, not the MFC, C#, etc!

As for you question. You can NOT send the text data via SendMessage
function. The problem is: - you send the pointer to a text data that points
to address in another process. So you cannot get that data unless using some
undocumented tricks.

My advise is to use more suitable IPC mechanism for such purposes. For
example, memory mapped files.
--
Vladimir (Windows SDK MVP)
Post by Mayur
I tried followinf but working fine fo int but how to do it for string using
user custome message
in c#
[DllImport("User32.dll")]
public static extern int FindWindow(string strClassName,string
strWindowName);
[DllImport("User32.dll")]
public static extern Int32 SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
[MarshalAs(UnmanagedType.LPStr)] string lParam);
public const int WM_APP = 0x8000;
public const int WM_DELETEALL =WM_APP + 0x100;
int wnd=FindWindow(null,"TestMfcSendMsgExe");
Form1.SendMessage(wnd,WM_DELETEALL,0,55);
and MFC Exe is like this
#define WM_DELETEALL WM_APP + 0x100
BEGIN_MESSAGE_MAP(CTestMfcSendMsgExeDlg, CDialog)
ON_MESSAGE (WM_DELETEALL, OnDeleteAll)
END_MESSAGE_MAP()
LRESULT CTestMfcSendMsgExeDlg::OnDeleteAll(WPARAM wParam, LPARAM lParam)
{
MessageBox("Hello","Mayur",MB_OK);
}
I am getting the message box after using SendMessage() in c# exe but i want
to send text(string ) information.
I need help..
Regards,
Mayur.
Loading...