Calling the ANSI Version of a DLL Function

By default, the Microsoft VM assumes that the ANSI version of the MessageBox function is the one that is needed. If you import the MessageBox function using @dll.import (without a modifier) as follows:

/** @dll.import("USER32") */
  static native int MessageBox(int hwnd, String text,
                               String title, int style);

The Microsoft VM will go through the following steps:

  1. The strings "text" and "title" are converted to ANSI null-terminated strings.

  2. The VM attempts to find an export named MessageBox in USER32.DLL.

  3. This attempt fails. The VM then appends an "A" onto the name and looks for an export named MessageBoxA.

  4. This attempt succeeds, and the VM invokes the MessageBoxA function.