teixeira Posted April 10, 2007 Posted April 10, 2007 Hello, I'm using a 3rd part DLL via Add reference i my C# project and sometimes the DLL generate a messagebox with an error and an OK button. I would like to know if its possible to automatically and programatically do the "OK Click" or how to destroy this window. This windows is not a separeated proccess so i cannot kill it using System.Diagnostics.Process any idea?? I heard about windows handle and maybe with p/invoke but i can see how can i do it. Thanks in advance, Quote
*Experts* Nerseus Posted April 10, 2007 *Experts* Posted April 10, 2007 This is not super fun or easy to do, but possible. I can't release the code my company's developed, but it revolves around the API calls for SetWindowsHookEx, UnhookWindowsHookEx, CallNextHookEx and a few others to look for a window created with a class name of "#32770" - the magic value for a standard windows messagebox. The idea is this: 1. Call SetWindowsHookEx - this takes a param for a delegate that will get called on certain hooked events. 2. In the delegate, check the message type looking for HCBT_CREATEWND (value = 3). 3. Get the class name of the created window - compare to the magic value above. 4. Make sure to call CallNextHookEx (another API) 5. At some point (I can't recall when and not obvious from the code) much later, probably sometime before shutting down your application, call UnhookWindowsHookEx. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
teixeira Posted April 10, 2007 Author Posted April 10, 2007 Hi, sure i understand that you can't expose the code. I'm used to deal with apis but make a deeper search using the keywords you gave me to try to solve my problem. Thanks a lot, Teixeira Quote
teixeira Posted April 10, 2007 Author Posted April 10, 2007 With your help Nerseus providing the name of the apis i found a great ready to use piece of code at Codeproject.com here's the link if someone else need: http://www.codeproject.com/cs/miscctrl/CsMsgBoxTimeOut.asp?df=100&forumid=90151&exp=0&select=947436 Best regards, Tiago Teixeira Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.