|
|
|||||||||||||||
Aliasing (Method Renaming)Sometimes you want to use a name for the Java method that is different from the name that the DLL uses when it exports the function. For example, you might want to have the Java name start with a lowercase letter so that it conforms to Java naming conventions. To do so, just use @dll.import with the entrypoint modifier as in the following example. /** @dll.import("USER32", entrypoint="GetSysColor") */ static native int getSysColor(int nIndex); You do not need to use aliasing to perform the ANSI/Unicode suffixing done by the Win32 APIs. The Microsoft Win32 VM for Java automatically takes care of this (see How the VM Chooses Between ANSI and Unicode). Aliasing is also unnecessary when accessing functions that have been exported by a .def file. Such names are typically exported using "stdcall mangling." That is, a method such as the following sample method would be renamed to _sample@8 (where 8 denotes the number of parameter bytes accepted by the function). extern "C" __declspec(dllexport) VOID sample(int x, int y){ ... } Microsoft® J/Direct automatically binds to stdcall-mangled names without an explicit entrypoint. The Microsoft VM automatically provides aliases for the following KERNEL32 API functions: CopyMemory (becomes RtlMoveMemory) MoveMemory (becomes RtlMoveMemory) FillMemory (becomes RtlFillMemory) ZeroMemory (becomes RtlZeroMemory)
|
© 1998 Microsoft Corporation. All rights reserved. Terms of use. |