This sample is located in \Samples\JDirect\Simple.
Description
Using the Sample
Key Project Files
Technologies Demonstrated
This sample uses the @dll.import directive to call the MessageBox API.
To run the sample
Run Go.bat in the \Samples\JDirect\Simple directory.
This class contains the call by @dll.import to USER32.DLL. There is a try-catch code block that notifies the user if Microsoft® J/Direct is correctly installed, or it displays one of two error messages if J/Direct is incorrectly installed or non-existent.
For the following code to work, you must import the com.ms.win32 package, which is included with the Microsoft® Win32® API classes for J/Direct.
/* Copyright (C) 1997 Microsoft Corporation. All rights reserved. * * This example calls the MessageBox API using the new @dll.import * directive. * */ import com.ms.win32.*; public class Simple { public static void main(String args[]) { try { User32.MessageBox(0, "MessageBox successfully called.", "Java", 0); } catch (UnsatisfiedLinkError ule) { System.err.println("Caught exception: " + ule); System.err.println("Probably wrong version of Java compiler."); } } }