Form-less applications

Thoth

Active member
Joined
Jun 27, 2003
Messages
26
Im trying to design some small applications, and these applications dont necessarily need to have forms, in fact it is better if they dont. All I want is the program to run, give a message that its run, and then quit.

In Visual Studio .NET 2003, when I try to create an Empty Project (using VB .NET), and I start writing my Main, I notice I cant use many of the functions I normally could in a Windows Application, like SendKeys, for example. Is there any way I can get all the functions I need without having to deal with forms?
 
You can still use the SendKeys class in a formless project; when you create the project, right click the References item in the Solution Explorer and click Add. Find System.Windows.Forms.dll in the list and add it to the project references list.

You can use SendKeys now by using
Code:
System.Windows.Forms.SendKeys.Send("mooo")
Or, at the top of your .vb file (above the Class declaration line) put
Code:
Imports System.Windows.Forms
Then youll be able to access the SendKeys class like this:
Code:
SendKeys.Send("moo")
 
This code wont compile, saying that theres no suitable main method. Can anyone tell me what I need to do to make this thing happy?

Imports System.Windows.Forms
Program to insert a comment with the current name and date into the open application.
Public Class CommentHeader
Sub Main()
Dim Name, Time As String
Get the current time.
Time = System.DateTime.Now.ToString
Get the name of the user logged in.
Name = Environment.UserName
Send the information to the appropriate application.
SendKeys.Send("" & Time & " " & Name)
End Sub
End Class
 
Last edited by a moderator:
Back
Top