c# - Registering an application to a URI Scheme -


i have wpf app have registered uri scheme doing following.

hkey_classes_root -->myappname    -->shell       -->open          -->command             (default) = "c:\pathtomyapp\app.exe" 

fantastic! however, application enforces 1 instance can run @ time. how can detect app running , example bring foreground?

you can use named mutex detect application running. or, if have gui app, can inherit form visualbasic's singleinstance application , , routhgly same you.

  public class singleinstancecontroller     : windowsformsapplicationbase   {     public singleinstancecontroller()     {       // set whether application single instance       this.issingleinstance = true;        this.startupnextinstance += new         startupnextinstanceeventhandler(this_startupnextinstance);     }      void this_startupnextinstance(object sender, startupnextinstanceeventargs e)     {       // here control when other instance       // invoked apart first one.       // have args here in e.commandline.        // custom code should run on other instances     }      protected override void oncreatemainform()     {       // instantiate main application form       this.mainform = new form1();     }   }  [stathread] static void main(string[] args) {       singleinstancecontroller controller = new singleinstancecontroller();   controller.run(args); } 

it not matter whenever write code in c#, class avaliable part of .net framework , languages.

and here wrapper wpf


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -