/// <summary> /// Checks to see if the currently running instance of the sprite editor /// is associated with the .scn file extension. /// </summary> /// <remarks>Currently only attempts to check/associate if the currently /// logged in user is a windows administrator. Have not fully /// investigated whether you really need unrestricted access to the registry /// to create/edit the required registry keys (in HKEY_CLASSES_ROOT), or /// if there is a way to do the association as a limited user. In /// the mean time, we will err on the side of caution.</remarks> static void VerifyScnRegistry() { System.Security.Principal.WindowsIdentity winIdent = System.Security.Principal.WindowsIdentity.GetCurrent(); System.Security.Principal.WindowsPrincipal winPrincipal = new System.Security.Principal.WindowsPrincipal(winIdent); if (winPrincipal.IsInRole( System.Security.Principal.WindowsBuiltInRole.Administrator)) { FileAssociationHelper file = new FileAssociationHelper(".scn"); if (!file.IsOpener || !file.IsEditor) { DialogResult res = System.Windows.Forms.MessageBox.Show( "This application is currently not associated with the .scn file extension.\n\nWould you like it to be?", "File Association", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (res == DialogResult.Yes) { file.Associate(); } } } }