64-bit Windows Hello World Application (Delphi and C++)

From RAD Studio
Jump to: navigation, search

Go Up to 64-bit Windows Application Development

This "Hello World" console application demonstrates the essential steps for creating a 64-bit Windows application. The application uses the 64-bit Windows target platform, a console window, an event, and will display a dialog in response to a user action. Because the RAD Studio IDE is a 32-bit Windows application, a 64-bit Windows target is cross-platform.


To create the 64-bit Windows "Hello World" application:

Connect to or Run the IDE on a 64-bit Windows System

You need to use either a 64-bit Windows development system or a remote 64-bit Windows target system connected to the 32-bit Windows development system where RAD Studio is installed.

  • If you are using a Win32 development system:
    • In order to run a Win64 application using the IDE on a Win32 development system, you need to install and run the Platform Assistant on a 64-bit Windows remote machine, and create, assign, and test the connection of a connection profile that describes the connection to PAServer on the 64-bit Windows machine, as described in the first three steps in this topic, and in Steps in Creating Multi-Device Applications.
    • If you create a Win64-only application (one that has not been compiled with the Win32 target platform and has no associated connection profile) and then you attempt to run the application on your Win32 development system, the following message appears:
Unable to create process: path.file.exe is not a valid Win32 application.

Run the Platform Assistant on Your 64-bit Windows System

  1. The Platform Assistant needs to be running on both the development PC and the remote 64-bit Windows:
    • If the Platform Assistant server is already installed on the remote 64-bit Windows system, go to the next step.
    • If the Platform Assistant server is not yet installed on the 64-bit Windows system, install it.
      Paclient.exe, the Platform Assistant Client Application is installed on your development system when you install RAD Studio.
  2. Open a cmd window on the 64-bit Windows system.
  3. Change the directory (cd) to the directory that contains the Platform Assistant (paserver.exe).
  4. Run the Platform Assistant by entering:
  5. When you are prompted to set a password, enter an optional password string. This is the password that will be required from any connection profile connecting to this instance of the Platform Assistant. To set no password, press Enter.
The Platform Assistant displays a sign-on message and its command prompt (>).

Create a connection profile for the Win64 target

  1. Choose Tools > Options > Connection Profile Manager.
  2. Click Add. The Create a Connection Profile wizard opens.
  3. On the first page of the wizard (Profile information):
    • In Profile name, enter a name for the connection profile.
    • In Platform, select the platform where the Platform Assistant server is running, in this case 64-bit Windows.
    • Click Next.
  4. On the second page of the wizard (Remote machine information):
    • In Remote machine (IP adress or Machine name), enter the name or the IP address of the target machine.
    • Leave Port number as the default, 64211.
    • In the Password field:
      • Enter the optional password string that was set when you started the Platform Assistant that you are connecting to.
      • If no password has been set for the Platform Assistant, leave this field blank.
      • To search for a *.passfile (an encrypted password file created using paserver.exe for sharing with other users), click the ellipsis (...) and navigate to the directory that contains the *.passfile. See Generating and Using an Encrypted Password File.
    • Click Test Connection.
      • If the connection fails, verify the target machine name or IP address (try pinging them on the cmd window), and then ensure that the Platform Assistant is installed and running on the target machine.
      • If the connection succeeds (or fails), click Next.
Note: You can create a connection profile even if the connection to the target has not yet succeeded. However, a valid connection profile is necessary at several critical times during cross-platform application development, that is, running, debugging, and deploying.

Create and configure a console application for the 64-bit Windows target

  1. Choose File > New > Console Application - Delphi or File > New > Console Application - C++Builder
    • For C++ only, in the New Console Application (C++) dialog box, make sure that Target Framework is set to None, Multi-threaded is unchecked, and Console application is checked (it might be grayed as well). Then click OK.
  2. In the Project Manager, right-click the Target Platforms node, and click Add Platform:
    Add Platform121.png
  3. On the Select Platform selection box, select Windows 64-bit or Windows 64-bit (Modern) , enable the Make the selected platform active checkbox, and click OK:
    Select Platform121.png

Do the following steps only if you are using a Win32 development system connected to a Win64 target system:

  1. Right-click the Windows 64-bit or Windows 64-bit (Modern) platform in the Project Manager to display the following context menu:
    Target Properties.png
    On the context menu, select Properties to assign a connection profile to this platform (the Platform Properties dialog box opens).
  2. In the Platform Properties dialog box, select the connection profile that you created for this application, and click OK. The profile name is now displayed next to the 64-bit Windows platform in the Project Manager.

Write the code

In the Code Editor, modify the code generated from the template:

  1. For C++ only, add after the other #include directives:
    #include <iostream>
  2. Add the code to say hello and to wait for the Enter key.

    • For Delphi, enter the following code in the try block (before the except keyword):
       Writeln('Hello, World!');
    • For C++, enter the following code before the line return 0;:

       std::cout << "Hello, World!" << std::endl;
  3. Save and name the application (File > Save).

Run the console application on the 64-bit Windows target

  1. Choose Run > Run Without Debugging or click the green Run button RunWithoutDebugging2.png .
  2. If RAD Studio displays: The project must be compiled before it can be deployed. Continue?, click Yes.
  3. On the target machine, the "Hello, World!" message is displayed at the Platform Assistant prompt. Press the ENTER key.
  4. After your console application terminates:
    • If you are using a 64-bit development system, the console window closes.
    • If you are using a 64-bit target system, the Platform Assistant redisplays its command prompt (>).

Debug the application

To debug your application in the IDE, use any of the standard Run commands:

You can also use the Load Process or the Attach to Process command to start the debugger.

All of these commands:

  • Transfer the required files to the target machine, based on the current assigned profile.
  • Run the application in debug mode.

Using the integrated debugger in the IDE to debug a 64-bit Windows application is very similar to using the integrated debugger to debug a native Win32 application.

See Also