Implementing a Shell Context Menu Handler In VB6

Filed under Uncategorized

I won’t go over the details of doing this here. There is a excellent run through online at O’Reilly. Check here. Specifically, it’s chapter 4 of J.P. Hamilton’s book “Visual Basic Shell Programming”.

I suppose it’s so dated now that they’re making it available online free. Not sure whether that’s a good thing, or a bad indicator of the age of tools I’m using<g>.

At any rate, this is an excellent reference if you happen to be doing this.

Specifically, the part about modifying the VTable on the fly to handle some of the IContextMenu methods is very good.

But the part that really had me smacking my head was the “Restore the VTable during object termination” section.

Duh! No wonder I was having some weird, after my context menu handler had popped up and done it’s thing, Explorer would crash kind of moments.

This is one of those times when telecommuting can be a drag. Having a co-worker glance over my shoulder probably could have caught that kind of mistake much earlier than when I caught it.

Moral of the story: If you’re gonna manually jack up COM VTable pointers, always put ’em back they way you found ’em.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*