DDE Poke

The following example sends data to DDE Server. You can use our DDE Server example.

final String SERVICE = "MyServer";
final String TOPIC = "MyTopic";
final String ITEM = "MyPoke";

try
{
    final DDEClientConversation conversation = new DDEClientConversation();
    // We can use UNICODE format if server prefers it
    //conversation.setTextFormat(ClipboardFormat.CF_UNICODETEXT);

    System.out.println("Connecting...");
    conversation.connect(SERVICE, TOPIC);

    System.out.println("Please, enter data to poke or 'exit' to quit");
    try
    {
        byte[] buff = new byte[1024];
        int ret_read = 0;
        do
        {
            ret_read = System.in.read(buff);
            if (ret_read > 0)
            {
                String data = new String(buff, 0, ret_read);
                data = data.trim();

                if (data.equals("exit"))
                    break;

                System.out.println("Sending:" + data);
                conversation.poke(ITEM, data);
            }
        }
        while ((ret_read > 0));
    }
    finally
    {
        conversation.disconnect();
    }
}
catch (DDEMLException e)
{
    System.out.println("DDEMLException: 0x" + Integer.toHexString(e.getErrorCode()) + " " + e.getMessage());
}
catch (DDEException e)
{
    System.out.println("DDEClientException: " + e.getMessage());
}
catch (Exception e)
{
    System.out.println("Exception: " + e);
}

Download PokeExample.java
Download all examples and binaries

Command line to run example:

java -cp .;pretty-tools-JDDE-2.0.4.jar PokeExample