Show: Delphi C++
Display Preferences

64-bit Windows "Hello World" Cross-Platform Application

From RAD Studio XE2
Jump to: navigation, search

Go Up to 64-bit Cross-Platform Application Development for Windows


This "Hello World" console application demonstrates the essential steps for creating a 64-bit Windows application in Delphi. 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.

Contents

Steps

To create the cross-platform 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. For more details, see Connecting Your PC to a Win64 PC.

Note: If you are using a Win32 development system, you can create a Win64-only application (one that has no Win32 target platform). However, if you attempt to run an application that is Win64-only and has no associated remote profile, the following message appears:
Unable to create process: path.file.exe is not a valid Win32 application.
In order to run a Win64 application using the IDE on a Win32 development system, you need to create, assign, and test the connection of a remote profile that describes the 64-bit Windows target, and install and run the Platform Assistant on the target platform, as described in this topic and in Steps in Creating Cross-Platform Applications.

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 is already installed on the remote 64-bit Windows system, go to the next step.
    • If the Platform Assistant is not yet installed on the 64-bit Windows system, install the Platform Assistant on the target platform using setup_paserver.exe.
      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:
    paserver
  5. When you are prompted to set a password, enter an optional password string. This is the password that will be required from any remote 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 remote profile for the Win64 target

  1. Choose Tools > Options > Remote Profiles.
  2. Click Add. The Create a Remote Profile wizard opens.
  3. On the first page of the wizard (Profile information):
    • In Profile name, enter a name for the remote profile.
    • In Platform, select the target platform, in this case 64-bit Windows.
    • Click Next.
  4. On the second page of the wizard (Host machine information):
    • In Host 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 (typically, in the same directory with paserver.exe on the target platform).
    • 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 remote profile even if the connection to the target has not yet succeeded. However, a valid remote profile is necessary at several critical times during cross-platform application development, that is, running, debugging, and deploying.

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

  1. Choose File > New > Other. The New Items dialog box appears.
  2. Select Delphi Projects and then double-click Console Application.
  3. In the Project Manager, right-click the Target Platforms node, click Add Platform:
    AddTargetPlatform2.png
  4. On the Select Platform selection box, select 64-bit Windows, enable the Make the selected platform active checkbox, and click OK:
    SelectPlatform64.png
  5. Right-click the 64-bit Windows platform in the Project Manager to display the following context menu:
    AddActivate64B.png
    On the context menu, select Assign Remote Profile to assign a remote profile to this platform (the Select Remote Profile dialog box opens).
  6. In the Select Remote Profile for '64-bit Windows' Platform dialog box, select the remote profile that you created for this Hello World 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. Add the code to say hello and wait for the Enter key. Enter the following Delphi code in the try block (before the except keyword):
     Writeln('Hello, World!');
     Readln;
  2. Save and name the application (File > Save).

Run the cross-platform console application on the 64-bit Windows target

  1. Choose Run > Run Without Debugging.
  2. 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. After your cross-platform console application terminates, the Platform Assistant redisplays its command prompt (>).

Debug the cross-platform application

To debug your cross-platform 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 cross-platform application is very similar to using the integrated debugger to debug a native Win32 application.

See Also

Personal tools
Previous Versions
In other languages