views:

111

answers:

3

I'm currently using SetWindowsHookEx to inject my DLL into another process, however it does not get loaded right away. I noticed that if I manually click the window, it will get loaded then, so I'm guessing it is waiting for some type of message to get the activation rolling? I'm currently getting it activated with a

SetForegroundWindow(otherAppHwnd);
SetForegroundWindow(myAppHwnd);

But this seems like a hack, and doesn't always work (i.e. the otherAppHwnd is minimized to the taskbar.

Any pointers would be great!

Edit: It is a CBT Hook

A: 

What kind of hook did you register?

Lloyd
I edited the question with this info
emostar
A: 

I've successfully used this:

SendMessage(otherAppHwnd, WM_NULL, 0, 0);

to achieve what you want, but only with lower-level hooks like WH_GETMESSAGE, never a CBT hook. It might work. 8-)

RichieHindle
Nope, doesn't work for CBT hooks
emostar
A: 

It seems that this is not possible.

So instead of forcing my way around this, I decided to just roll with it and make my design be able to handle this.

emostar