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
Who is Participating?
UrosVidojevicConnect With a Mentor Commented:
#include <windows.h>

int main()
      MessageBox(0,"Message text...","Message title!",0);
      return 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?
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) {}

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.