![]() |
|
#1
|
|||
|
|||
yet another winapi problemI am trying to make a program that adds customizable animations when a window is minimized. but since this is a standalone program that has to affect every open window (and therefore almost every running program) it needs to have a global (that is, systemwide) hook. now, MSDN mentions that the hook procedure for such a hook must be in an external DLL. but i don't know how to do this. can i just stick the function in the DLL?
|
|
#2
|
|||
|
|||
|
come on, i know someone out there is just DYING to help with this problem...
|
|
#3
|
|||
|
|||
|
all right, answered my own question through experimentation. I ended up putting the function in the DLL, and including declspec(dllexport) in the declaration/definition. and I enclosed the prototype in extern "C" { } so that the name would not be mangled and I would be able to access the function from outside the DLL.
|
|
#4
|
||||
|
||||
|
when i rad th question, i thout your asking how to use the hook procedurs, but actually your anser sems to be different than i expected, your asking how to use a dll function..
i used hook before for InternetExplorer(not all running app), to catch the contents and event of the IE window, but i used it in the exe app not in a dll, not sure why it must be in dll for your case.. ![]() __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#5
|
|||
|
|||
|
yeah, i just didn't understand the concept of a DLL. the reason I need a DLL instead of just having my hook procedure in my program, is because I need a global (all threads) hook. You only needed to put a hook on one thread--Internet Explorer. but I need to monitor all threads, and Windows annoyingly requires that my hook procedure must be in a DLL. now, I set the hook from within min_anim.exe, of course, but the ShellHookProc is in min_anim.dll. i have one last question related to this topic: since I am only using the ShellHookProc in min_anim.dll, do I still need a DllMain()?
|
|
#6
|
||||
|
||||
|
i think youll need your dllMain but you wont hav to altr any code in the dll main.. just export your hook function..
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#7
|
|||
|
|||
|
thanks.
btw I learned a lesson when I finally got the hook to work: NEVER EVER do something in the hook procedure that causes your hook to be triggered! I had the hook procedure for the WH_SHELL hook displaying a message box. now, obviously a message box is a window, and so is the static control that holds the text (unless MessageBox() uses TextOut() or DrawText(), I wouldn't know) and the button you click. this is a problem because WH_SHELL hooks are triggered by window creation and activation. so each time my filter function was called, I caused it to be called again at least three times. Yikes! you can imagine the rest, I had to fight even to get Task Manager up and functioning (although agonizingly slowly) to kill the process. |
|
#8
|
||||
|
||||
|
yep, that would b tiresome.. hooking sometime is dangerous, i tried to hook the winzip befor to get its password window, and try to bruteforce the password window (i lost my pwd
![]() __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
Recent GIDBlog
Developing GUIs with wxPython (Part 4) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need advice on a disturbing problem | JUNK KED | Open Discussion Forum | 6 | 31-Mar-2005 13:51 |
| driver problem | Carrie7979 | Computer Hardware Forum | 7 | 27-Jan-2005 11:39 |
| Tee chart problem | Arun | C++ Forum | 0 | 01-Sep-2004 23:23 |
| Multithreading problem | YellowFish | C++ Forum | 5 | 26-Jul-2004 01:36 |
| Another FX 5600 problem (but with details that might shed light on this) | BobDaDuck | Computer Hardware Forum | 2 | 16-Apr-2004 07:53 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The