@@ -531,10 +531,53 @@ void AddPackageFolder()
531
531
}
532
532
}
533
533
534
+ void AddContextMenuRegistry ( )
535
+ {
536
+ RegistryKey key = Registry . CurrentUser . OpenSubKey ( "Software\\ Classes\\ Directory\\ Background\\ shell" , true ) ;
537
+ if ( key != null )
538
+ {
539
+ var appName = "UnityLauncher" ;
540
+ key . CreateSubKey ( appName ) ;
541
+
542
+ key = key . OpenSubKey ( appName , true ) ;
543
+ key . SetValue ( "" , "Open with UnityLauncher" ) ;
544
+ key . SetValue ( "Icon" , "\" " + Application . ExecutablePath + "\" " ) ;
545
+
546
+ key . CreateSubKey ( "command" ) ;
547
+ key = key . OpenSubKey ( "command" , true ) ;
548
+ var executeString = "\" " + Application . ExecutablePath + "\" " ;
549
+ executeString += " -projectPath \" %V\" " ;
550
+ key . SetValue ( "" , executeString ) ;
551
+ SetStatus ( "Added context menu registry items" ) ;
552
+ }
553
+ else
554
+ {
555
+ SetStatus ( "Error> Cannot find registry key: Software\\ Classes\\ Directory\\ Background\\ shell" ) ;
556
+ }
557
+ }
534
558
559
+ void RemoveContextMenuRegistry ( )
560
+ {
561
+ RegistryKey key = Registry . CurrentUser . OpenSubKey ( "Software\\ Classes\\ Directory\\ Background\\ shell" , true ) ;
562
+ if ( key != null )
563
+ {
564
+ var appName = "UnityLauncher" ;
565
+ key . DeleteSubKeyTree ( appName ) ;
566
+ SetStatus ( "Removed context menu registry items" ) ;
567
+ }
568
+ else
569
+ {
570
+ SetStatus ( "Error> Cannot find registry key: Software\\ Classes\\ Directory\\ Background\\ shell" ) ;
571
+ }
572
+ }
535
573
536
574
#region Buttons and UI events
537
575
576
+ private void btnRemoveRegister_Click ( object sender , EventArgs e )
577
+ {
578
+ RemoveContextMenuRegistry ( ) ;
579
+ }
580
+
538
581
private void chkMinimizeToTaskbar_CheckedChanged ( object sender , EventArgs e )
539
582
{
540
583
Properties . Settings . Default . minimizeToTaskbar = chkMinimizeToTaskbar . Checked ;
@@ -737,8 +780,11 @@ private void btnAddAssetStoreFolder_Click(object sender, EventArgs e)
737
780
}
738
781
}
739
782
740
-
741
-
783
+ private void btnAddRegister_Click ( object sender , EventArgs e )
784
+ {
785
+ AddContextMenuRegistry ( ) ;
786
+ }
742
787
#endregion
788
+
743
789
}
744
790
}
0 commit comments