VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Want to use the standard inputbox as a login box? This code well show you how to hook the standard

Ayman Elbasha  (1 Submission)   Windows API Call/Explanation   VB 6.0   Unknown Difficulty   Sun 21st October 2001   Mon 8th February 2021

Want to use the standard inputbox as a login box? This code well show you how to hook the standard input box by using some API function to

API Declarations


Option Explicit
' IMPORTANT NOTE:
' Demo project showing how to use the Secured InputBox
' by Ayman Elbasha
' this demo is released "as is" without warranty or guaranty of any kind.
' In other words, use at your own risk.

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private m_lMsgHandle As Long
Private m_lhHook As Long
Private Const ES_CENTER = &H1&

Private Function GetMessageBoxHandle(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If lMsg = HCBT_ACTIVATE Then
m_lMsgHandle = wParam
UnhookWindowsHookEx m_lhHook
m_lhHook = 0
End If
GetMessageBoxHandle = False
End Function

Private Sub InputBoxTimerUpdateEvent(hWnd As Long, uiMsg As Long, idEvent As Long, dwTime As Long)
Dim res As Long

If m_lMsgHandle = 0 Then Exit Sub
res = FindWindowEx(m_lMsgHandle, 0, "Edit", "")
SendMessage res, 1052, 42, ByVal 0&
SendMessage res, &H441, ES_CENTER, ByVal 0&
End Sub




Public Function InputBoxEx(sMsgText As String, Optional sTitle As String = "Secured InputBox") As String
Dim lTimerUpdate As Long

m_lhHook = SetWindowsHookEx(WH_CBT, AddressOf GetMessageBoxHandle, App.hInstance, GetCurrentThreadId())
lTimerUpdate = SetTimer(0, 0, 0, AddressOf InputBoxTimerUpdateEvent)
InputBoxEx = InputBox(sMsgText, sTitle)
KillTimer 0, lTimerUpdate
End Function


Rate Want to use the standard inputbox as a login box? This code well show you how to hook the standard (1(1 Vote))
Want to use the standard inputbox as a login box? This code well show you how to hook the standard .bas

Want to use the standard inputbox as a login box? This code well show you how to hook the standard Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters