|
-
March 14th, 2005, 12:42 AM
#1
Read the string send through PostMessage
I have an application which has 2 components. One component is a COM dll (C++). The other is the Dot Net (C#) User Interface. I am Doing a PostMessage in the COM dll and handling this postmessage in the C# User Interface. My problem is that I am not ablr to get the string which I am sending through postmessage LPAram.
Here is the code.
COM code to send the string :
CString sRestoreProg(_T("CHKPT_RESTORE_DEVICE"));
UINT nRestoreDevice = RegisterWindowMessage(sRestoreProg);
CString name = "Kdevice ";
CString * s = new CString(name);
int i = name.GetLength();
PostMessage( hRestHWnd, nRestoreDevice , i+1, (LPARAM)s );
Here is the C# code:
int m_gettext = RegisterWindowMessageA("CHKPT_RESTORE_DEVICE");
public struct MyStruct
{
public string str;
}
In the wndproc()...
if(m.Msg == m_gettext)
{
MyStruct strLPARAM = (MyStruct) m.GetLParam(typeof(MyStruct));
}
Result : strLParam.str gives "K".. which is the first alphabet of the sent string "kdevice".
How to get the whole string put of this IntPtr?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|