Click to See Complete Forum and Search --> : add code in exe


mayankmalik
August 5th, 2001, 11:09 PM
I have to develop an application which adds a dialog box to any exe file
Eg . when u run notepad , a dialog box opens up saying “hello world” and then notepad runs as ususal
Could someone guide me how to go about doing this in VB , or tell me if there is any source code for such a software

Cimperiali
August 6th, 2001, 02:47 AM
I think your best shot is to write a program that should run at startup and intercept all new windows appearing, in order to display a dialog. It may be done using EnumWindows Api. Here an example of using this api:

'Add this code to a form
private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'set the form's graphics mode to persistent
me.AutoRedraw = true
'call the Enumwindows-function
EnumWindows AddressOf EnumWindowsProc, byval 0&
End Sub
'Add this code to a module
Declare Function EnumWindows Lib "user32" (byval lpEnumFunc as Long, byval lParam as Long) as Boolean
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (byval hwnd as Long, byval lpString as string, byval cch as Long) as Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (byval hwnd as Long) as Long
public Function EnumWindowsProc(byval hwnd as Long, byval lParam as Long) as Boolean
Dim sSave as string, Ret as Long
Ret = GetWindowTextLength(hwnd)
sSave = Space(Ret)
GetWindowText hwnd, sSave, Ret + 1
Form1.print Str$(hwnd) + " " + sSave
'continue enumeration
EnumWindowsProc = true
End Function





Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater