Overloading the Function

Another way to declare the WinHelp function is to overload the function for each possible type:

/** @dll.import("USER32") */
static native boolean WinHelp(int hwnd, String szHelpFile, 
                              int cmd, int dwData);
   
/** @dll.import("USER32") */
static native boolean WinHelp(int hwnd, String szHelpFile, 
                              int cmd, String dwData);   

/** @dll.import("USER32") */
static native boolean WinHelp(int hwnd, String szHelpFile, 
                              int cmd, MULTIKEYHELP dwData);   

/** @dll.import("USER32") */
static native boolean WinHelp(int hwnd, String szHelpFile, 
                              int cmd, HELPWININFO dwData);

You cannot handle a polymorphic return value using overloading because Java methods cannot be overloaded on return value only. Therefore, you need to give each variant of the function a different Java name and use the entrypoint modifier to link them all to the same DLL method. See Aliasing (Method Renaming) to learn more about renaming DLL methods.