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

Posted on 2007-10-14
Last Modified: 2013-11-07
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?
Question by:stormist
    LVL 7

    Accepted Solution

    #include <windows.h>

    int main()
          MessageBox(0,"Message text...","Message title!",0);
          return 0;
    LVL 7

    Expert Comment

    LVL 10

    Author Comment

    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?
    LVL 7

    Expert Comment

    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) {}


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now