Simple unmanaged C++ code to show a messagebox in windows

I'm familiar with C# but now I'm trying to understand unmanaged C++. What would be the shortest code for an unmanaged, non-dependent on .net framework, win32 program that simply shows a messagebox and exits when ok is pressed?
LVL 10
stormistAsked:
Who is Participating?
 
UrosVidojevicConnect With a Mentor Commented:
#include <windows.h>

int main()
{
      MessageBox(0,"Message text...","Message title!",0);
      
      return 0;
}
0
 
stormistAuthor Commented:
In VS2005, which is the proper way to open a project of this sort without it inserting all that extra code? Is a win32 console app ok?
0
 
UrosVidojevicCommented:
You may do that if you don't want extra code, but console window will also appear when you execute program.

So maybe best solution is to create Win32 application and then insert this code in

int APIENTRY WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow) {}

function.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.