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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:18:23+00:00 2026-05-11T00:18:23+00:00

How would you open a file (that has a known file/app association in the

  • 0

How would you open a file (that has a known file/app association in the registry) into a ‘running instance’ of the application it’s supposed to open in? An example would be, I have Excel open and I click on an XLS file…..the file opens up in the current Excel instance. I want to do this for a custom application…how does the eventing/messaging work that ‘tells’ the current instance that it needs to open a file? Is there a ‘file watcher’ that looks for a request to do so etc? 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. 2026-05-11T00:18:23+00:00Added an answer on May 11, 2026 at 12:18 am

    What you want to do is inherit a class from WindowsFormsApplicationBase, setting the protected IsSingleInstance property to true:

    // This should all be refactored to make it less tightly-coupled, obviously. class MyWindowsApplicationBase : WindowsFormsApplicationBase {   internal MyWindowsApplicationBase() : base()   {     // This is a single instance application.     this.IsSingleInstance = true;      // Set to the instance of your form to run.     this.MainForm = new MyForm();   } } 

    The Main method of your app then looks like this:

    // This should all be refactored to make it less tightly-coupled, obviously. public static void Main(string args[]) {   // Process the args.   <process args here>    // Create the application base.   MyWindowsApplicationBase appBase = new MyWindowsApplicationBase();    // <1> Set the StartupNextInstance event handler.   appBase.StartupNextInstance = <event handler code>;    // Show the main form of the app.   appBase.Run(args); } 

    Note the section marked <1>. You set this up with an event handler for the StartupNextInstanceEvent. This event is fired when the next instance of your app is fired when you have a single instance application (which you specified in the constructor of MyWindowsApplicationBase). The event handler will pass an EventArgs-derived class which will have the command line arguments which you can then process in the running instance of your app.

    Then, all you have to do is set the file associations normally for the file types you want your app to process, and you are set.

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

Sidebar

Related Questions

I would like to open an OleDbConnection to an Excel file that's in memory
I have an WinMo app and I would like to open a file from
I would like to open a file using open file dialog. If the opened
How would I go about showing an open file (or file select) dialog in
I would like to delete every double space in a file open in vim,
i dont have microsoft access but would like to open an mdb file, is
I would like to know if a file is open by any process (including
I would like to to create a 2-step file uploader: Open dialog. Select one
I'm would like to know how I can open a specific file using a
I would like the designer to be able to open the same solution file

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.