You may have had such a demand, some pop-up boxes may need to be manually closed, so very troublesome, I refer to the relevant information, the C # program to automatically close the popup box for your reference
1 //gets the handle to the popup box and hides the function. 2 usingSystem.Runtime.InteropServices;//This is a required namespace. 3 classSearchwindow4 {5 6 Private Const intWm_close =0x0010;7[DllImport ("User32.dll", EntryPoint ="FindWindow")]8 Private Static externIntPtr FindWindow (stringLpclassname,9 stringlpwindowname);Ten[DllImport ("user32.dll", EntryPoint ="SendMessageA")] One Private Static extern intSendMessage (INTPTR hwnd,intWmsg, IntPtr WParam,stringlParam); A PublicSearchwindow () - { - the } - Public voidCloseWindow (stringLpclassname,stringlpwindowname) - { - +IntPtr mhandle= FindWindow (NULL, lpwindowname); - if(Mhandle! =IntPtr.Zero) +SendMessage (Mhandle, Wm_close, IntPtr.Zero,NULL); A Else at { - return; - } - } - } - ////Hide the console in - usingSystem.Runtime.InteropServices;//This is a required namespace. to + - classShadeconsole the { *[DllImport ("user32.dll", EntryPoint ="ShowWindow", SetLastError =true)] $ Static extern BOOLShowWindow (IntPtr hWnd,UINTncmdshow);Panax Notoginseng[DllImport ("user32.dll", EntryPoint ="FindWindow", SetLastError =true)] - Public Static externIntPtr FindWindow (stringLpclassname,stringlpwindowname); the Public voidShade () + { AConsole.title ="Consolewin"; theIntPtr cwinptr = FindWindow ("Consolewindowclass","Consolewin"); + if(Cwinptr! =IntPtr.Zero) - { $ShowWindow (Cwinptr,0); $ } - } - } the - ///multi-threaded implementations, closed to the MessageBox or other forms;Wuyi the usingSystem.Threading;//multithreading is necessary. - Wu Public Static classmultithread - { About Public Static voidDoWork () $ { - -ThreadPool.QueueUserWorkItem (NewWaitCallback (s = = { - while(true) A { +Searchwindow SSS =NewSearchwindow (); the //Thread.Sleep ($); -s =NULL; $Sss.closewindow ("DidiSoft.Pgp.PGPLib","Didisoft OpenPGP Library for. NET"); the } the })); the } the}
View Code
Introduction to Usage:
1 "Call multithread. Dowork ();
2 "This popup box before calling MessageBox.Show (" message "," title "));
3 "Because the popup box blocks the main thread. So the other thread calls to be started before the main thread, so that he has been inquiring the main thread. To get a handle.
Tip: This is the use of Open source PGP encryption file, it has a time to verify, particularly troublesome, so just think about it, a draw off the popup box. Thank you!
Gets the handle of the popup box, closes the popup box