Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5992189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:29:45+00:00 2026-05-22T23:29:45+00:00

I am working in an application in this application I shall wait for some

  • 0

I am working in an application in this application I shall wait for some event in application 1 and when this event happen I shall sendmessage to application 2 which will perform something.

First API declaration

private const int HWND_BROADCAST = 0xffff;

 [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern int RegisterWindowMessage(string lpString);

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        static extern bool SendNotifyMessage(int hWnd, int Msg, int wParam, int lParam);

Application 1 Code

private string msgstr = "MYMESSAGE";              
public int  msg = RegisterWindowMessage(msgstr);
                if (msg == 0)
                {
                    MessageBox.Show(Marshal.GetLastWin32Error().ToString());
                }

                //SendNotifyMessage(HWND_BROADCAST, msg, 4848484, 8484865);

                SendNotifyMessage(HWND_BROADCAST, msg, 0, 0);

                MessageBox.Show(Marshal.GetLastWin32Error().ToString());

Application 2 Code

 static readonly int msg = RegisterWindowMessage("MYMESSAGE");
     protected override void WndProc(ref Message m)
        {
            if (m.Msg == msg)
            {
                MessageBox.Show(m.Msg.ToString() + " = from wndproc");
            }
            base.WndProc(ref m);
         }

Will somebody point out what is problem with this code.
I suspect there is problem in SendNotifyMessage

lparam and wparam
parameters

Will somebody suggest me any other alternative to achieve this behaviour!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:29:45+00:00Added an answer on May 22, 2026 at 11:29 pm

    HWND_BROADCAST is pretty dangerous.. I know it’s highly unlikely but what if another application also handled your message??

    Anyway, that aside, have you taken a read of http://msdn.microsoft.com/en-us/library/ms644953.aspx

    The most basic way to debug an issue with your code (as it’s WINAPI based) would be to use GetLastError. You should always be checking the return value of methods to see if they succeed, so ensure it’s returning zero (which means it worked). If it’s not, and you get an error such as access denied, try running with either UAC Disabled or as an Administrator (Vista+).

    When a message is blocked by UIPI the
    last error, retrieved with
    GetLastError, is set to 5 (access
    denied).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a nut I'm cracking these days Application I'm working on has some
I'm working on this application that's sort of like a blog. I'm thinking about
I'm working on a document application and part of this application I've to add
I am working on an Location Based Application. In this application I am using
I'm working on an application that gets content from feeds in C#. This content
Has anyone got this working in a web application? No matter what I do
Has anyone seen this error when working with a PHP application out of dynamic
So I'm working on this VB to C# web application migration and came across
I ran into this dilemma when working on an ASP.net web application using Web
I'm working with XML data from an application where we get XML like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.