'Get foreground window using GetForegroundWindow API. Very useful to develop security programs and
'Get foreground window using GetForegroundWindow API. Very useful to develop security programs and system logger programs
API Declarations
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Rate 'Get foreground window using GetForegroundWindow API. Very useful to develop security programs and
(1(1 Vote))
'http://www.geocities.com/marskarthik
'http://marskarthik.virtualave.net
'Email: [email protected]
Private Sub Form_Load()
'Set window on top
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1
End Sub
' Display the title bar text of the foreground window.
Private Sub Timer1_Timer()
Dim hwnd As Long
Dim length As Long
Dim wntxt As String
Dim rval As Long
hwnd = GetForegroundWindow() 'Get the foreground window
length = GetWindowTextLength(hwnd) + 1
wntxt = Space(length)
rval = GetWindowText(hwnd, wntxt, length) 'Get title bar text
wntxt = Left(wntxt, length - 1)
Label1.Caption = wntxt
End Sub
'Get foreground window using GetForegroundWindow API. Very useful to develop security programs and Comments
No comments yet — be the first to post one!
Post a Comment