Executable directory where application is running from?

This is the first post on google so I thought I’d post different ways that are available and how they compare. Unfortunately I can’t figure out how to create a table here, so it’s an image. The code for each is below the image using fully qualified names. My.Application.Info.DirectoryPath Environment.CurrentDirectory System.Windows.Forms.Application.StartupPath AppDomain.CurrentDomain.BaseDirectory System.Reflection.Assembly.GetExecutingAssembly.Location System.Reflection.Assembly.GetExecutingAssembly.CodeBase New … Read more

VB.NET equivalent of C# property shorthand?

There is no shorthand for Visual Studio 2008 or prior for VB.NET. In Visual Studio 2010 and beyond, you can use the following shorthand: Public Property FirstName as String This will be handled as your short version in C# is – I think they call it “Auto Property” See also: Auto-Implemented Properties (Visual Basic)

Listen to key press when the program is in the background

You can use P/Invocation to be able to use WinAPI’s GetAsyncKeyState() function, then check that in a timer. <DllImport(“user32.dll”)> _ Public Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short End Function Const KeyDownBit As Integer = &H8000 Private Sub Timer1_Tick(sender As Object, e As System.EventArgs) Handles Timer1.Tick If (GetAsyncKeyState(Keys.LWin) And KeyDownBit) = KeyDownBit AndAlso (GetAsyncKeyState(Keys.O) … Read more