As your attempt to hide application was so naive, I would advice another naive suggestion which may satisfy you. Create a
normal application without console and without any UI. To do this, you application option "Output type" should be "Windows Application". The simplest way to do this is to start from console application and to change Project's "Properties" => "Application" => "Output Type" to "Windows Application". Don't create any Forms or Windows, of course.
You can do more advanced variant of this. Suppose you want to start application with UI, but then press a button "Go to background" and remove UI which would continue to run as some invisible background application perhaps using some data defined by the used in the UI part. The simplest way to do this is to create a normal
System.Windows.Forms
application. Here is the simplest way: Your "Go to background" button should set an internal Boolean
Background
property of the main form and exit the
System.Windows.Forms.Application
. Another internal property (I called it
InvisibleApplicationData
of the type of the same name) can be returned from the form when it is closed. If this property
Background
is set, the rest of the code will run your invisible-part application:
using System;
using System.Windows.Forms;
namespace Invisible {
internal class InvisibleApplicationData { }
internal static class InvisibleApplication {
internal static void Run(InvisibleApplicationData data) { }
}
static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MyUiPartForm form = new MyUiPartForm();
Application.Run(form);
if (form.Background)
InvisibleApplication.Run(form.InvisibleApplicationData);
} Main
}
}
Of course it will only hide your application from Alt+Tab and system tray, not from Task Manages, but who cares?
If you don't want to play this simple game, go with System Service as Tarakeshwar advised.
Start here:
http://msdn.microsoft.com/en-us/library/d56de412(v=VS.100).aspx[
^].
—SA