views:

36

answers:

1

Is there a way to intercept a MsgBox() from an external application and block it using VB.Net?

For this discussion, let's say the MsgBox Title is "SQL Application" and the Message is "SQL Error - Try Again".

I have found some examples of looking for the MsgBox to pop-up (by watching for the Window title) and then sending key(s) to press OK, but I was curious if the whole process could be avoided. Otherwise, the user still sees a MsgBox or a "flash", even if it's only temporary.

Is it possible to avoid this?

A: 

Well, you could something like detours (see http://research.microsoft.com/en-us/projects/detours/), and write a detour for messagebox that you load into your process, BUT there are several issues:

1) it's 32 bit only, unless you pay for the pro version 2) the development effort involved may be non-trivial, esp if you dont have a lot of inhouse C/C++ experience. I suppose you could write a managed wrapper for detours, but that sounds kind of involved too. 3) You cant use it commercially without the pro version.

is this an app you've inherited?

weloytty
No, it's tied to a control that I've placed on a form. It has a MsgBox that fires in certain circumstances, but I need to hide it. There is no event for the control that fires so I can't intercept it that way.
Jeff
And for those wondering, no... it's not a licensing (nag screen) message that's coming up that I'm trying to block. It's all legit.
Jeff
What's the control? Maybe someone can come up with an alternatve.
weloytty
No, they can't. Thanks, but I'd prefer to stay focused on the question. I appreciate your answer. I checked out the detour. I was expecting something a little more "built-in" to .Net. If there are no other answers, I'll accept yours. It technically does what I'm asking.
Jeff