Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sending message to C# application from C++ DLL

Posted on 2003-12-11
4
Medium Priority
?
487 Views
Last Modified: 2011-09-20
I have a C++ Win32 DLL that gets called by Winlogon.exe whenever a user locks and unlocks the PC. So, whenever a user locks the computer Winlogon.exe calls a function in my DLL.
Now, the whole purpose is to have my C# application react on those events.
So how do I send a message to the C# application (which will be running) from the C++ DLL?
This is part 2 of a 3-part question :) For part 1 see:
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20819936.html

Since this is C# section, I’ll also accept comments that answer just C# part, and I’ll post the C++ part in C++ section if needed.

Thanks,
Alex
0
Comment
Question by:astankovic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Assisted Solution

by:Agarici
Agarici earned 400 total points
ID: 9921289
you could just send a message to the window of your c# app. some user defined message
the handle of the c# form is easy to obtain, how to have it in the dll? export a funtion from that dll, a function that sets the value of a HWND variable in the dll and call that function from your c# app as it starts.

hope this helps.

A.
0
 
LVL 4

Author Comment

by:astankovic
ID: 9922522
Ok, I see what you are saying.
But how do I "listen" for that message in C#? What class would I use?
Could you provide me with a link where I can see some sample code?

Thanks,
Alex
0
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 400 total points
ID: 9926200
0
 
LVL 5

Accepted Solution

by:
jjacksn earned 1200 total points
ID: 9926843
astankovic,

you want to override WndProc

protected override void WndProc(ref Message aMessage)
{
      if(aMessage.Msg == myCustomMessage1)
      {
                         //Do something
      }
               base.WndProc(ref aMessage);
}

this will trap all messages sent to the form.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question