Share via


Syntax for @dll.import

The @dll.import directive should be placed just above the method declaration. The syntax of the directive is:

  /**@dll.import("LibName",<Modifier>)*/
  ...method declaration...;

LibName is the name of the DLL that contains the function you want to invoke. Modifier is optional, and the value that you should supply for it varies depending on your needs. In the method declaration, you can use the function name that the DLL uses, or you can give the method a different name by using aliasing. For information on aliasing, see Aliasing (Method Renaming). The Java data types that you choose for the parameters and for the return value of the method should be types that map to the types of the DLL function parameters and return value. See How Data Types are Marshaled for more information about how Java data types map to native types.

The following table presents the @dll.import syntax for several situations that are described in this section.

Situation Required Syntax Explanation
Calling Win32 DLLs
/**@dll.import("Libname")*/
Calling OLE APIs
/**@dll.import("Libname", ole)*/
Aliasing
/**@dll.import("Libname", entrypoint="DLLFunctionName")*/
In the method declaration, use the Java name that you selected.
Linking by Ordinal
/**@dll.import("Libname", entrypoint="#ordinal")*/
"ordinal" is a 16-bit integer, specified in decimal, that indicates the DLL function that you are importing.