• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 869
  • Last Modified:

Restoring a CString From a LPARAM

I am trying to pass data between two applications via SendMessage.

I can pass integers back and forth fine, but I am have problems passing any char data.


CWnd* pWnd = CWnd::FromHandle(hWnd);

char *text =  "this won't come through";  // doesn't work
int x = 90;  // passes fine

pWnd->SendMessage( MY_MESSAGE, (WPARAM) x, (LPARAM), text);




LRESULT CMainFrame::OnExternalMessage(WPARAM wParam, LPARAM lParam)
{

   // wParam is OK
   
    CString FileName = (char *) lParam;
   
  //   FileName  is  = ""  no good


What am I doing wrong ?

Thanks,

-Eric
0
nielsew
Asked:
nielsew
  • 2
1 Solution
 
chensuCommented:
Two applications have their own process address space. You need an Interprocess Communication (IPC) mechanism. In your case, use WM_COPYDATA.
0
 
chensuCommented:
Using WM_COPYDATA for IPC
http://msdn.microsoft.com/library/psdk/winbase/ipc_34o3.htm

Inter-Process Communication Using WM_COPYDATA
http://codeguru.developer.com/win32/ipcdemo.shtml
0
 
nielsewAuthor Commented:
thank you! thank you!

I should have posted this question about 3 hours ago!

-Eric
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now