CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: add code in exe

  1. #1
    Join Date
    Feb 2001
    Location
    canada
    Posts
    19

    add code in exe

    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



  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: add code in exe

    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: [email protected]
    '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
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured