Building a Windows Hello World Console Application

From RAD Studio
Jump to: navigation, search

Go Up to How To Build VCL Forms Applications

This "Hello World" console application demonstrates the essential steps for creating a Windows application in Delphi or C++. The application uses Windows, a console window, an event, and will display a dialog in response to a user action.

To create the "Hello world" console application

  1. Create a Windows console application.
  2. Create the logic.
  3. Run the application.

To create a Windows console application

  1. Choose File > New > Other... .The New Items dialog box appears.
  2. In the New Items dialog box, select either Delphi Projects or C++Builder Projects and then double-click Console Application.
  3. For C++, in the New Console Application dialog box, make sure that VCL Forms and Multi-threaded are unchecked, and Console application is checked. Then click OK.

To associate code with the console window

  1. In the code template that is displayed in the Code Editor:
    • For Delphi, enter the following statements after the try keyword and before the except keyword:
    Writeln('Hello, World!');
    Readln;
    • For C++, enter the following after #pragma hdrstop:
    #include <iostream>
  2. For C++, enter the following code after the opening brace ({):.
    std::cout<<"Hello, World!"<<std::endl;
    std::cin.ignore();
  3. Save the application.

To run the "Hello World" application

  1. Choose Run > Run .The application compiles and displays a console window with your "Hello World" message.
  2. Press the ENTER key. The console window closes when the program terminates.

See Also