views:

95

answers:

1

I have a IE BHO plugin that I only want to be enabled when the user launches IE from my program (The program starts IE using CreateProcess()).

I don't want this BHO to be enabled when a user launches IE from outside my program, as that would mean any problems in the BHO could potentially mess up the user's normal browsing experience.

What's the best way to do this?

One way would be to register the BHO, launch IE and then quickly unregister the BHO. This seems kind of messy though, as a crash in the program that launches IE could cause the BHO to remain registered.

+1  A: 

Your approach is very error-prone, I advise against it. Instead, your BHO should always load with IE, but by default it should do nothing. What you need then is a way to tell it "start filtering" or "start recording" or whatever.

You've got lots of choices from there. The simplest is a flag somewhere in the environment (a semaphore, a disk file). You can have a special url, like mybho:start that it watches for.

I've done this many times, it works.

Edit Yes, the BHO will be loaded into memory, together with any DLLs it depends on (though you can wait and load them only when needed via LoadLibrary()).

egrunin
Like the idea of waiting on a flag/unique URL, but the BHO will still be loaded into memory along with any dlls the BHO depends on.
watsonmw
Guess I'll work on refactoring the BHO, so that it delayloads as much as possible and limit the amount of static initializations done when it's loaded.
watsonmw