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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:34:26+00:00 2026-05-17T00:34:26+00:00

I am making an image uploader (upload image to image hosting website) and I’m

  • 0

I am making an image uploader (upload image to image hosting website) and I’m having some issues passing an argument (image location to an already running application)

  • First of all let’s say MyApp.exe is always running
  • Whenever I right click on an image I have added an item in the default windows context menu that says “Upload image”.
  • When that’s clicked it needs to pass the location to the already running application.

My program.cs:

static class Program
{
    [DllImport("user32.dll")]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("user32.dll")]
    static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr
    wParam, IntPtr lParam);

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

    [STAThread]
    static void Main(params string[] Arguments)
    {
        if (Arguments.Length > 0)
        {
    //This means that the the upload item in the context menu is clicked
    //Here the method "uploadImage(string location)"
    //of the running application must be ran
        }
        else
        {
    //just start the application
            Application.Run(new ControlPanel());
        }
    }
}

Note that the ControlPanel class doesn’t have a visible form, only a tray icon is present since a form is not needed.

Could I get any help on how to do this?

  • 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-17T00:34:27+00:00Added an answer on May 17, 2026 at 12:34 am

    I have figured it out, so awesome thanks for the person who posted the http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a5bcfc8a-bf69-4bbc-923d-f30f9ecf5f64 link, this is exactly what I was looking for!

    Here’s a the full solution:

    static class Program
    {
        [STAThread]
        static void Main(params string[] Arguments)
        {
            SingleInstanceApplication.Run(new ControlPanel(), NewInstanceHandler);
        }
    
        public static void NewInstanceHandler(object sender, StartupNextInstanceEventArgs e)
        {
            string imageLocation = e.CommandLine[1];
            MessageBox.Show(imageLocation);
            e.BringToForeground = false;
            ControlPanel.uploadImage(imageLocation);
        }
    
        public class SingleInstanceApplication : WindowsFormsApplicationBase
        {
            private SingleInstanceApplication()
            {
                base.IsSingleInstance = true;
            }
    
            public static void Run(Form f, StartupNextInstanceEventHandler startupHandler)
            {
                SingleInstanceApplication app = new SingleInstanceApplication();
                app.MainForm = f;
                app.StartupNextInstance += startupHandler;
                app.Run(Environment.GetCommandLineArgs());
            }
        }  
    }
    

    Thanks alot all, and especially the person who posted that link I mentioned above but I guess he deleted his answer?

    Regards,
    Kenny

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

Sidebar

Related Questions

I am making an application that does some custom image processing. The program will
How do I go about making an image or section of the page full
I'm making a simple Image Debugger Visualizer. Code is below. I'm not sure if
After making some changes in my models (eg. new field in a model and
Im making a small python script to upload files on the net. The script
i am making an upload with Ajaxupload plugin and i am using this function
I am trying to secure my PHP Image upload script and the last hurdle
I am working on an image upload script and ran into this problem. Using
I'm making the script for easy upload many files. I've tried fyneworks plugin ,
I'd like to rank a collection of landscape images by making a game whereby

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.