[Solved] How to get the currently running application using vb6


You can get the window title for current application. Based on window title and window handle, you can get sufficient details.

Code is in vb.net

<DllImport("user32.dll")> _
Private Shared Function GetForegroundWindow() As IntPtr
End Function

<DllImport("user32.dll")> _
Private Shared Function GetWindowText(hWnd As IntPtr, text As StringBuilder, count As Integer) As Integer
End Function

Private Function GetCurrentWindowTitle() As String
    Const  nChr As Integer = 256
    Dim str As New StringBuilder(nChr)
    Dim handle As IntPtr = GetForegroundWindow()

    If GetWindowText(handle, str, nChr) > 0 Then
        Return str.ToString()
    End If
    Return Nothing
End Function

solved How to get the currently running application using vb6