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 6776749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:03:57+00:00 2026-05-26T16:03:57+00:00

I have this application (Windows form application written in Visual C++) from a colleague

  • 0

I have this application (Windows form application written in Visual C++) from a colleague of mine and I face some serious problems. The application is neither a service neither a normal application, I mean it has a GUI but most of the time it runs in background (it should react as a service but it’s not). This application is preventing the user to log off, and I need to be able to do that.

I know that Windows sends the WM_QUERYENDSESSION message to all running applications when the user tries to log off. I have tried to catch this message on my WndProc() function and to kill the application by force but it only works once. When I login again and try to log off the operation is not terminated because my application won’t close.

If I try to use SessionEnding event, the application is only put to the system tray and remains there without logging off but this I believe it’s because the Form_Closing method performs this operation instead of closing the program (this was the requirement and I can’t change that).

Maybe another useful information is that the application starts automatically because it has an entry in the HKLM registry and there are always 2 instances of this application running (one should supervise the other one and restart it in case of crash but not in case of “manually” shut down).

Any suggestions will be well received.

Thanks.

  • 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-26T16:03:58+00:00Added an answer on May 26, 2026 at 4:03 pm

    Yes, this problem is caused by the form’s FormClosing event handler. You have to pay attention to the close reason and only cancel it when the user is closing the window. Like this:

        System::Void Form1_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
            // Do this *only* when the user closes the window
            if (e->CloseReason == CloseReason::UserClosing) {
                e->Cancel = true;
                this->Hide();
                // etc...
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using C# with a Windows Application Form. In this I have a
I have a C# Windows Form application that contains a menu with this event:
Assume i have a custom Windows application written in C#. This application has only
I have an existing application that is written in C++ for Windows. This application
I have single-thread windows form application written with VB.NET and targeting Framework 1.1 .
Hi I have a c# windows form written in .Net 4. In the application
I have an application that is written in VB.NET, using the System.Windows.Forms.Form as the
I have a windows form application written in C# and running on a Windows
I have windows form application written in VC ++ . I want to change
I have a Windows Application in C#. This application interacts with a remote mySQL

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.