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

  • Home
  • SEARCH
  • 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 8121183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:24:12+00:00 2026-06-06T05:24:12+00:00

I have a small launcher program, it loads a Splash screen on it’s own

  • 0

I have a small launcher program, it loads a Splash screen on it’s own thread and displays it. If a set of conditions are met it needs to launch another application and keep the splash screen visible till the other application says it is ok to close the splash screen.

enter image description here

The Launcher will always have a lifetime that starts before Child App and ends after Child App closes.

Here is some snippets of relevant code

The common DLL:

namespace Example.Common
{
    public partial class SplashScreen : Form
    {
        public SplashScreen()
        {
            InitializeComponent();
        }

        static SplashScreen splashScreen = null;
        static Thread thread = null;

        static public void ShowSplashScreen()
        {
            // Make sure it is only launched once.
            if (splashScreen != null)
                return;

            thread = new Thread(new ThreadStart(SplashScreen.ShowForm));
            thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }

        // A static entry point to launch SplashScreen.
        static private void ShowForm()
        {
            splashScreen = new SplashScreen();
            Application.Run(splashScreen);
        }

        // A static method to close the SplashScreen
        static public void CloseForm()
        {
            splashScreen.Close();
        }
    }
}

The Inital Launcher:

/// <summary>
/// This application is a small launcher to launch the real graphical launcher. It is small and lightweight and should be rarely be updated.
/// It will call the ProgramLauncher, the program launcher will return in it's status code the PID of the instance it launched or -1
/// if no subsequent program was started.
/// </summary>
[STAThread]
static void Main()
{
    //Show the Splash screen;
    Example.Common.SplashScreen.ShowSplashScreen();

    //(Snip)

    if (rights == UserRights.None)
    {
        SplashScreen.CloseForm();
        MessageBox.Show("Your user does not have permission to connect to the server.", "Unable to logon", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return;
    }
    //If the user has full desktop access, give it to them and launch a new instance of the launcher.
    else if (rights.HasFlag(UserRights.FullDesktopAccess))
    {
        Process explorer = new Process();
        explorer.StartInfo.FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe");
        if (explorer.Start() == false)
        {
            MessageBox.Show("Explorer failed to start.");
        }
        else
        {
            //Close the splash screen.
            SplashScreen.CloseForm();

            //If the user can shadow start a new instance of the launcher inside explorer.
            if (rights.HasFlag(UserRights.ShadowNormalUser) || rights.HasFlag(UserRights.ShadowDemoUser))
            {
                //Start a new copy of the program so people can use it to shadow easily.
                var shadowProc = new Process();
                shadowProc.StartInfo.FileName = "ProgramLauncher.exe";
                shadowProc.StartInfo.UseShellExecute = false;
                shadowProc.Start();
            }
            explorer.WaitForExit();
        }
    }
    else
    {
        Process programLauncher = new Process();
        programLauncher.StartInfo.FileName = "ProgramLauncher.exe";
        programLauncher.StartInfo.UseShellExecute = false;

        //Launch the graphical launcher.
        programLauncher.Start();
        programLauncher.WaitForExit();

        //Check to see if the graphical launcher launched some other process.
        if (programLauncher.ExitCode >= 0)
        {
            //If there was a pid, don't close the micro launcher till after it closes.
            Process runningProcess = Process.GetProcessById(programLauncher.ExitCode);
            runningProcess.WaitForExit();
        }

    }
}

What is the easiest way to let ProgramLauncher close the SplashScreen instance MicroLauncher created?

  • 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-06-06T05:24:13+00:00Added an answer on June 6, 2026 at 5:24 am

    You need to have SplashScreen pass it’s window handle (HWND) to ProgramLauncher. Then, ProgramLauncher can use the SendMessage winapi function to send a WM_SYSCOMMAND message to the target window:

    public const int WM_SYSCOMMAND = 0x0112;
    public const int SC_CLOSE = 0xF060;
    SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
    

    In WinForms, you can get a form’s native handle with Handle.
    The platform invoke code for SendMessage is here.

    At least I don’t see an easier way now, but I think it’s easier than any IPC mechanism out there.

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

Sidebar

Related Questions

I have a module that needs to run a small .Net command-line program to
I have a small command-line application written in C that acts as a wrapper/launcher
I am currently have a small program in Common Lisp, which I want to
I have built a small program for school that runs perfectly when i run
I have a small C# program to modify a xml file which is located
I'm making a small launcher program for my Java program, the idea being that
have small problem, and would very much appreciate help :) I should convert byte
I have small database of business and their addresses. Using the Google Geocode API
I have small test app: Socket socket = new Socket(jeck.ru, 80); PrintWriter pw =
I have small web app that generate PDF files as a report. I'm trying

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.