Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2005

Tip: Looking for answers? Try searching our database.

SendMessage help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ken Beauchesne - 26 Sep 2005 19:09 GMT
I have a stand alone c++ program that uses  SendMessage to communicate with
a stand alone C# program.

The c++ program looks like this

hWind has previously been determined;

wchar_t wts[] = L"123456";

::MessageBox(NULL,wts,L"",MB_OK);        // just to display it gets set
SendMessage(hWind,WM_GET_ENG_UNITS_MESSAGE,0,(LPARAM)(&wts));    // send it
to the C# program
::MessageBox(NULL,wts,L"",MB_OK);    // contents after the C# program

-----------------------------------------

The C# side catches the message and :

string EuS = Marshal.PtrToStringUni(msg.LParam);

EuS now reads correctly 123456

here lies my problem how can I minuplate the string on the c++ side from
the C# side by using the msg.LParam.

TIA
Ken
Robert Jordan - 26 Sep 2005 20:28 GMT
Hi Ken,

> I have a stand alone c++ program that uses  SendMessage to communicate with
> a stand alone C# program.
[quoted text clipped - 20 lines]
> here lies my problem how can I minuplate the string on the c++ side from
> the C# side by using the msg.LParam.

You cannot do that. Even with 2 C++ apps. Your WM_GET_ENG_UNITS_MESSAGE
message is probably identical with a Window message that takes
a LPTSTR as a LPARAM parameter. That's why the pointer got mapped
at all.

If you want to safely exchange data between the apps, you have
to use WM_COPYDATA:

http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows_Messages/Simple_Int
erprocess_Communication/article.asp

http://www.codeproject.com/csharp/wm_copydata_use.asp

Rob

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.