The Microsoft.VisualBasic.dll assembly contains the "WinformsFormsApplicationBase" class, which contains some functionality, such as the thing you want. You can also use this class in a C # application.
Just create a class that inherits from this class. Set the SingleInstance property to true and override the required methods.
This means that you have a link to the VisualBasic.dll assembly, which may be considered a drawback, but I think that this is by far the simplest and easiest solution.
More information can be found here.
source share