Example #1
0
 /// <summary>
 /// Handles the AdminRequested event of the CurrentLurker control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void CurrentLurker_AdminRequested(object sender, EventArgs e)
 {
     if (AdminRequestHelper.RequestAdmin())
     {
         this._closing = true;
     }
 }
        /// <summary>
        /// Runnings the instance.
        /// </summary>
        /// <returns>The other running instance.</returns>
        public static Process RunningInstance()
        {
            var currentProcess = Process.GetCurrentProcess();
            var processes      = Process.GetProcessesByName(currentProcess.ProcessName);

            try
            {
                var currentFilePath = currentProcess.GetMainModuleFileName();
                foreach (var process in processes)
                {
                    if (process.Id != currentProcess.Id)
                    {
                        if (process.GetMainModuleFileName() == currentFilePath)
                        {
                            return(process);
                        }
                    }
                }
            }
            catch (System.ComponentModel.Win32Exception)
            {
                AdminRequestHelper.RequestAdmin();
            }

            return(null);
        }