Redirect Message Box Messages,
-
Hallo, I have a Windows Service written in Visual C++. It`s a loop that does certain things, and starts from the beginning after waiting a few seconds. My problem is, that when there occurs an error in the code, a messagebox pops up. And the code is not executed anymore, because you have to click on "ok" first. The messagebox is showed from some external library functions, so I can`t go to the source code. Is there any possibility to redirect all message boxes to a logfile or something like that, and continue executing the program without a click by the user? Thank you!
-
Hallo, I have a Windows Service written in Visual C++. It`s a loop that does certain things, and starts from the beginning after waiting a few seconds. My problem is, that when there occurs an error in the code, a messagebox pops up. And the code is not executed anymore, because you have to click on "ok" first. The messagebox is showed from some external library functions, so I can`t go to the source code. Is there any possibility to redirect all message boxes to a logfile or something like that, and continue executing the program without a click by the user? Thank you!
Well, first of all, if there are errors popping up, shouldn't you rather try to figure out what causes them and try to fix it, besides, maybe the user has to/wants to know about these problems, so "supressing" message boxes might not be a good idea. Depending on how the message boxes are displayed, i can think of a possible way to do what you want if you insist.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
-
Well, first of all, if there are errors popping up, shouldn't you rather try to figure out what causes them and try to fix it, besides, maybe the user has to/wants to know about these problems, so "supressing" message boxes might not be a good idea. Depending on how the message boxes are displayed, i can think of a possible way to do what you want if you insist.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
Code-o-mat wrote:
i can think of a possible way to do what you want
Please show how can the ::MessageBox() can be suppressed and corresponding message be directed to some file.
-
Code-o-mat wrote:
i can think of a possible way to do what you want
Please show how can the ::MessageBox() can be suppressed and corresponding message be directed to some file.
Sorry for the late answer, wasn!t near net access for a day. So, you could try hooking the MessageBoxA and/or MessageBoxW API functions and provide your own implementations to write to a log file. I don't know what you are actually doing so i can't really judge but i still don't think supressing message boxes intended for the user is a BAD IDEA. Anyways, for api hooking, see API hooking revealed[^] here on Code Project.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
-
Sorry for the late answer, wasn!t near net access for a day. So, you could try hooking the MessageBoxA and/or MessageBoxW API functions and provide your own implementations to write to a log file. I don't know what you are actually doing so i can't really judge but i still don't think supressing message boxes intended for the user is a BAD IDEA. Anyways, for api hooking, see API hooking revealed[^] here on Code Project.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
Thank you for the Link, I will try this. As I described i`m working at a Windows Service. It is a loop that changes things in a database and send mails and things like that, so there is no user in front of the computer at all, and when a message box pops up, the whole service stops, and mails are not sent anymore. So this service has to continue running when an error occurs. I just want the error in a logfile to see what happened and fix it later.
-
Thank you for the Link, I will try this. As I described i`m working at a Windows Service. It is a loop that changes things in a database and send mails and things like that, so there is no user in front of the computer at all, and when a message box pops up, the whole service stops, and mails are not sent anymore. So this service has to continue running when an error occurs. I just want the error in a logfile to see what happened and fix it later.
I see, with no user at the box it makes more sense. Tell me if you run into trouble with the hooking and i will help if i can.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <