64-bit Windows Hello World Application (Delphi and C++)
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.
Contents
- 1 Steps
- 1.1 Connect to or Run the IDE on a 64-bit Windows System
- 1.2 Run the Platform Assistant on Your 64-bit Windows System
- 1.3 Create a connection profile for the Win64 target
- 1.4 Create and configure a console application for the 64-bit Windows target
- 1.5 Write the code
- 1.6 Run the console application on the 64-bit Windows target
- 1.7 Debug the application
- 2 See Also
Steps
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 Win64 development system, you can skip the first steps described here, and start at Create and configure a console application for the 64-bit Windows target.
- 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
- 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.
- Open a cmd window on the 64-bit Windows system.
- Change the directory (
cd
) to the directory that contains the Platform Assistant (paserver.exe). - Run the Platform Assistant by entering:
paserver
- 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
- Choose Tools > Options > Connection Profile Manager.
- Click Add. The Create a Connection Profile wizard opens.
- 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.
- 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.
Create and configure a console application for the 64-bit Windows target
- 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.
- In the Project Manager, right-click the Target Platforms node, and click Add Platform:
- 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:
Do the following steps only if you are using a Win32 development system connected to a Win64 target system:
- Right-click the Windows 64-bit or Windows 64-bit (Modern) platform in the Project Manager to display the following context menu:
- On the context menu, select Properties to assign a connection profile to this platform (the Platform Properties dialog box opens).
- 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:
-
For C++ only, add after the other
#include
directives:#include <iostream>
-
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!'); Readln;
-
For C++, enter the following code before the line
return 0;
:std::cout << "Hello, World!" << std::endl; std::cin.ignore();
-
For Delphi, enter the following code in the try block (before the except keyword):
- Save and name the application (File > Save).
Run the console application on the 64-bit Windows target
- Choose Run > Run Without Debugging or click the green Run button .
- If RAD Studio displays: The project must be compiled before it can be deployed. Continue?, click Yes.
- On the target machine, the "Hello, World!" message is displayed at the Platform Assistant prompt. Press the
ENTER
key. - 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:
- Run > Run (F9)
- Run > Step Over (F8)
- Run > Trace Into (F7)
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.