@@ -531,10 +531,53 @@ void AddPackageFolder()
531531 }
532532 }
533533
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+ }
534558
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+ }
535573
536574 #region Buttons and UI events
537575
576+ private void btnRemoveRegister_Click ( object sender , EventArgs e )
577+ {
578+ RemoveContextMenuRegistry ( ) ;
579+ }
580+
538581 private void chkMinimizeToTaskbar_CheckedChanged ( object sender , EventArgs e )
539582 {
540583 Properties . Settings . Default . minimizeToTaskbar = chkMinimizeToTaskbar . Checked ;
@@ -737,8 +780,11 @@ private void btnAddAssetStoreFolder_Click(object sender, EventArgs e)
737780 }
738781 }
739782
740-
741-
783+ private void btnAddRegister_Click ( object sender , EventArgs e )
784+ {
785+ AddContextMenuRegistry ( ) ;
786+ }
742787 #endregion
788+
743789 }
744790}
0 commit comments