AutoMode J/Direct Sample

This sample is located in \Samples\JDirect\Automode.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

This sample shows how to use the auto keyword in @dll.import for calling Microsoft® Win32® system APIs. The auto keyword instructs the Microsoft virtual machine (Microsoft VM) to use the GetVersion() API to determine whether the ANSI MessageBox (MessageBoxA) or the Unicode MessageBox (MessageBoxW) will be called. If the running platform is Microsoft® Windows® 95, the ANSI API is called. If the running platform is Microsoft® Windows NT®, the Unicode API is called.

This algorithm can be overridden by setting the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Java VM\DllImportDefaultType to one of the following DWORD values:

2: Select ANSI.

3: Select Unicode.

4: Perform the check as previously described.

This registry key is normally set only by the installation program. In addition, this sample shows how to programmatically learn whether the "auto" mode will choose ANSI or Unicode.

Using the Sample

To run the sample

Run Go.bat in the \Samples\JDirect\Automode directory.

Key Project Files

AutoMode.java

This class's main method contains a switch-case block that shows how to programmatically learn whether the auto mode will choose ANSI or Unicode. It does this by querying the com.ms.dll.DllLib.systemDefaultCharSize field.

Technologies Demonstrated

Microsoft J/Direct

© 1999 Microsoft Corporation. All rights reserved. Terms of use.