Results 1 to 6 of 6

Thread: SubClassing, Hooks...

  1. #1
    Guest

    Talking SubClassing, Hooks...

    Hi,

    I need to hook into a specific window.
    I tried to use SetWindowLong in order to change the window proc to my own callback function,
    but then I found out it only works if i use it on windows in my app.

    I need an explanation about global hooks.

    Any suggestions?

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    can't do it

    as far as I know. From VB you can only SubClass your own windows (the ones you've created through VB)

    Post #521

  3. #3
    Guest

    Unhappy

    Are you sure there's no way?

    What about the SetWindowsHookEx?

  4. #4
    Guest
    It's possible to intercept input/messages from all of the applications running on a system, but not using "pure" VB. The hook must be placed in a standard DLL; while VB can create OLE DLLs, it cannot create standard DLLs.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    DumpBin gives this for the Spy++ DLL:
    Code:
    Dump of file spyhk50.dll
    
    File Type: DLL
    
      Section contains the following exports for SpyHk50.dll
    
               0 characteristics
        32E71EBA time date stamp Thu Jan 23 08:18:02 1997
            0.00 version
               1 ordinal base
              40 number of functions
              40 number of names
    
        ordinal hint RVA      name
    
              2    0 00002FD0 GetWindowClass
              1    1 00001000 _DLLEntryPoint@12
              3    2 000012E0 _SpyxxCallWndProc@12
              4    3 000013B0 _SpyxxCallWndRetProc@12
              5    4 00001110 _SpyxxGetMsgProc@12
              6    5 00007030 gaaClasses
              7    6 00007060 gabMsgBuf
              8    7 0000702C gcMsgPackets
              9    8 00007018 gcSubclass
             10    9 00007014 gfEnableSubclass
             11    A 00007010 gfHookEnabled
             12    B 00007000 gfOnWindows95
             13    C 00007008 ghhkCallHook
             14    D 00007004 ghhkMsgHook
             15    E 0000700C ghhkRetHook
             16    F 00009060 gmet
             17   10 0000A690 gmet3D
             18   11 0000A158 gmetAni
             19   12 0000A620 gmetCBX
             20   13 0000A678 gmetDT
             21   14 0000A148 gmetDlg
             22   15 0000A060 gmetEdit
             23   16 0000A3D8 gmetHK
             24   17 0000A168 gmetHdr
             25   18 0000A3E8 gmetLV
             26   19 0000A648 gmetMC
             27   1A 0000A3C0 gmetProg
             28   1B 0000A2E8 gmetStat
             29   1C 0000A1B8 gmetTB
             30   1D 0000A288 gmetTT
             31   1E 0000A4E8 gmetTV
             32   1F 0000A550 gmetTab
             33   20 0000A310 gmetTrk
             34   21 0000A398 gmetUpDn
             35   22 00008FA4 gmsgOtherProcessData
             36   23 00007024 goffRead
             37   24 00007028 goffWrite
             38   25 00008FA8 gopd
             39   26 0000701C gpidSpyxx
             40   27 00007020 gtidSpyxx
    I'll have to see how to find the function declarations.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81

    Wink

    Actually you should be able to do this from within VB5 and + using the addressOf operator along with callbacks.

    The actual hook must be done from a DLL.

    You should check out the June 1998 issue of Visual Basic Programmers Journal - Black belt programming section for code samples of this.

    There are also code samples for this on microsoft's VB site.

    You only need to get the handle for the window that you want to hook.

    You can enumerate through all top-level windows using code you can copy from : http://support.microsoft.com/support.../Q183/0/09.ASP

    This will show you how to get handles to virtually any kind of window.

    You should also check this page :
    http://support.microsoft.com/support.../Q242/3/08.ASP

    - which shows you how to get handles from app instances.

    You can do all kinds of things to another open app using these techniques - like minimizing, moving, and you can even add your own toolbars to them if you want to do a lot grueling code work.

    If you want to do global hooking then you'll probalbly have to use C,C++ or Delphi but I'm not sure about that.

    Take a look at - http://msdn.microsoft.com/library/ps...hooks_0837.htm

    - for a complete example of a hooking app in C.

    And remember "Failure to unhook the keyboard hook before exiting your application will result in errors, Invalid Page Faults, and data loss. This is caused by the system still pointing to your KeyboardProc() function, which no longer exists because it has not been notified of the change." So you should always test hooks in an .exe

    Note also that "Hooks do not always behave the same way in the IDE as they do in an EXE. Make certain that you test your solution in an EXE before you move on to other parts of your project."

    Check this stuff out and good luck.


    [Edited by hitcgar on 08-18-2000 at 12:30 PM]

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