javawinapinativedde

Making DDE calls from Java


Wondering if anyone has experience and/or sample code for making DDE calls from Java. I've done DDE using win32 calls from the stddde library (DdeInitialize, DdeClientTransaction), and could write a JNI wrapper for this, but I was thinking that it might be nice to do it from JNA

I also have some concerns about the fact that DDE calls need to occur from a thread with message pump, and I'm not entirely certain of how to force that in Java.

The calls we'll be doing are pretty simple (equivalent to VBA's DDInitiate, DDEExcecute and DDETerminate functions).


Solution

  • JNA now has a DDE implementation in its contrib repository (the compiled classes are available in the jna-platform artifact):

    https://github.com/java-native-access/jna/blob/master/contrib/platform/src/com/sun/jna/platform/win32/DdemlUtil.java

    The unit tests contain many usage examples:

    https://github.com/java-native-access/jna/blob/master/contrib/platform/test/com/sun/jna/platform/win32/DdemlUtilTest.java