I've created a WinService, unfortunately Win7 (and Vista) does not support Screen Capture from a service. I'm going to rewrite a program into something different than WinService, something that has no forms..
what will you suggest?
- Console Application has a console - I don't need any.
- WinForms app has a form - I don't need any.
Is it possible to remove a form from winforms application completely? I don't want to hide a proccess or anything, but I want it to work as a listener on the background (just like a service).
How will I close it? Easy! An alternative to "Stop service" should be "End task" from task manager.
- having no physical form and no focus is crucial condition.
EDIT:
thanks for the link! So I've removed form.cs completely, and made following changes to program.cs:
static class Program
{
static Thread workerThread;
[STAThread]
static void Main()
{
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
load();
workerThread.Start();
}
public static void load()
{
workerThread = new Thread(DoWork);
workerThread.SetApartmentState(ApartmentState.STA);
}
static void DoWork()
{
while (true)
{
string directory = (@"C:\10\new\"); string name = (".bmp");
string filename = String.Format("{0:hh-mm-ss}{1}", DateTime.Now, name);
string path = Path.Combine(directory, filename);
Bitmap bmp = new Bitmap(@"C:\10\1.bmp");
bmp.Save(path);
bmp.Dispose();
Thread.Sleep(1100);
}
}
do I need to make some other changes or it's ok as it is? I don't want my app to steal focus.. just a process must present.
- is "Application.Run();" needed?
- does this app has icon?