MessageBox(NULL, L"Can't connect on Server", L"Error", MB_SYSTEMMODAL); 

First, I’ll say that I brought MessageBox to a separate thread (so as not to wait for the user’s response), but the fact is that I need to make sure that after the process is closed

 ExitProcess(0); 

MessageBox remained open (because it indicates the notification to the user)

Please do not offer

  1. suspend the main thread (because I use a DLL, not the main program)
  2. Running a completely different program (I use a DLL instead of writing a program)

I use IDE Visual Studio 15 with the v140 toolkit.

    1 answer 1

    Your conditions can not be fulfilled.

    MessageBox does not run on its own, but as part of a process. Upon completion of the process, all its threads die, and the system forcibly destroys all windows belonging to the process. Therefore, the requirement that the other process not start immediately means that the dialog box will disappear with the completion of the process.


    Considering the problem pragmatically, I would refuse the requirement of one process, and run a single-line script on VBS:

     MsgBox "Can't connect to server", 4096, "Error" 

    (run cscript путь-к-файлу.vbs ) Yes, you have to drag a small file with you, or create it on the fly in a temporary directory.

    (Parameters for MsgBox described, for example, here .)

    • and if through bat and any rundll? - Grundy
    • @Grundy: You can, it is essentially the same. Simply writing VBScript is easier than looking for parameters for rundll. - VladD
    • @VladD thanks, helped - Castiel
    • @ Castiel: Please! - VladD