What type of project in Visual Studio should I use to create a "hidden" utility?
3 answers
Use the right tool for the job.
Create an empty project or class library. Add a new class (if you are using a class library template it will be generated already). Add a static method named Main
.
public class Class1
{
public static void Main()
{
// do your staff
}
}
Once the project is created, an .exe file will be generated that you can use.
No need for workarounds with hidden windows.
+3
source to share
You can use both. I especially prefer working with winform. just hide the window:
this.WindowState = FormWindowState.Minimized;
then
Rectangle bounds = this.Bounds;
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(bounds.Left,bounds.Top), Point.Empty, bounds.Size);
}
bitmap.Save("C://test.jpg", ImageFormat.Jpeg);
}
+1
source to share