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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:20:47+00:00 2026-05-22T15:20:47+00:00

I am spawning an application from c++ with ShellExecute, so I have the HINSTANCE

  • 0

I am spawning an application from c++ with ShellExecute, so I have the HINSTANCE of the app.

How can I close it now using that HINSTANCE? And can I use WaitForSingleObject() to wait for the app to finish?

  • 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-22T15:20:48+00:00Added an answer on May 22, 2026 at 3:20 pm

    First of all, an HINSTANCE is of very little use in modern versions of Windows — but what you have isn’t really an HINSTANCE anyway. The return from ShellExecute is really just a value greater than or less than 32, to indicate success or failure respectively.

    Fortunately, if you use ShellExecuteEx, you can get a process handle for the new process, and you can use that to control the process.

    The MSDN article that @Remus linked is decent, but (IMO) there’s another step that can be useful if the target application is (or might be) a console application. In this case, it usually won’t handle a WM_CLOSE message. You can, however, inject a DLL into the process, and have that do a clean(ish) shutdown from inside the process (for example, if it calls exit, and the target program is written in C, it’ll get a chance to flush and close files, run anything registered with atexit, etc., before dying).

    If that fails, you might want to use GenerateConsoleCtrlEvent to send it a control-break.

    Then, if all those fail to exit you call TerminateProcess.

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

Sidebar

Related Questions

I have an application that will be spawning multiple threads. However, I feel there
I have a .NET app that will be spawning tasks to run on an
I have an app that is using devise for authentication. Rails 3 on ruby
I have an application that runs transactions spanning over multiple databases on the same
I am using Rational Application Developer v7.0 that ships with an integrated test environment.
I have a lot of long-running activities and think that spawning this activity off
How would I go about spawning a separate process using a SQL Server 05/08
From a logical point of view an application may need dozens or hundreds of
We've got a winforms LOB application, which under normal circumstances should be started from
I have an enterprise application with around 2k concurrent users every day. These users

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.