This is a command line (aka console) based tool for querying text data from DDE servers. It is the counterpart to my much older GUI based tool called DDE Query.
The tool supports all the major DDE command types, such as XTYP_REQUEST, XTYP_ADVSTART, XTYP_POKE & XTYP_EXECUTE via similarly named commands. The basic format for invoking DDE Command is to run it with a command type and then provide any arguments using switches, e.g.
C:\> ddecmd command --option1 value1 --option2 value2
The arguments can be specified using either Windows style (e.g.
/option) or the
more modern style (e.g.
--option). Each switch has both a short name and a
longer name and you can see the list of all supported commands using "
Each command has its own help topic that describes itself and lists the switches
that are applicable, e.g.
ddecmd request --help.
This command invokes the
XTYP_WILDCONNECT transaction type to list the running
DDE servers and their supported topics. This transaction type is not always
supported by servers and is included more for development use. The output is
one server and topic per line, separated by a '|', the normal separator used
for DDE Links, e.g.
C:\> ddecmd servers Excel|System Excel|[Book1]Sheet3 Excel|[Book1]Sheet2 Excel|[Book1]Sheet1
request command is used to retrieve the value for one or more items from
the server. This is the
XTYP_REQUEST transaction type. The items must all be
from the same server as only a single server and topic can be specified.
C:\> ddecmd request --server REUTER --topic IDN_RWS --item "GBP=,BID ASK" --item "EUR=,BID ASK" +1.9058 +1.9062 +1.2981 +1.2982
By default the request assumes
CF_TEXT (i.e. ANSI text) for the
value format, but this can be overridden by using the
switch. See below for the format names.
When a single item is requested the output is just the value by itself. When
multiple items are requested each value is prefixed by the item name. For
complete control over the display format use the
switch which is detailed later, e.g.
C:\> ddecmd request --server REUTER --topic IDN_RWS --item "GBP=,MID" --output-format "%d %i -> %v" 2010-02-01 22:32:15 GBP=,MID -> +1.9058
Excel provides another way of expressing a DDE link that is more compact. The
--link switch can be used instead of specifying the server, topic
and item separately, e.g.
C:\> ddecmd request --link "REUTER|IDN_RWS!GBP=,BID ASK" +1.9058 +1.9062
Note: You can currently only specify a single item with the --link switch because it includes the server and topic, and only a single conversation is currently supported.
To set up one or more advise loops with the server use the
advise command. This
allows you to monitor the updates for a number of items and corresponds to the
XTYP_ADVDATA transaction types.
The same basic switches that are used with the
Request command can also be used with this one.
However, unlike the other commands, this causes ddecmd to run indefinitely and
so can only be stopped by pressing Ctrl+C.
C:\> ddecmd advise -s REUTER -t IDN_RWS -i "GBP=,BID ASK" -i "EUR=,BID ASK" +1.9060 +1.9062 +1.2981 +1.2986 +1.2980 +1.2982 +1.9059 +1.9064 +1.2978 +1.2983 +1.2982 +1.2984 +1.9059 +1.9062 <CTRL+C>
The poke command allows you to set a value for an item on servers that support
XTYP_POKE). Unlike the previous request and advise commands you can only set the value
for a single item and that value will be passed in CF_TEXT format, e.g.
C:\> ddecmd poke -s excel -t [book1]sheet1 -i R1C1 --value "test"
Note: The Poke command also supports the
--link switch as described earlier.
The final transaction type supported is
XTYP_EXECUTE via the
This is used to send a command string to a server, e.g.
C:\> ddecmd execute -s excel -t [book1]sheet1 --command "[App.Minimize]"
Note: The command doesn't support the
--format switch because
the DDE transaction type
XTYP_EXECUTE ignores it. Consequently the
command is always sent in CF_TEXT for an ANSI build and CF_UNICODETEXT for a
Unicode build. This is to work around an apparent bug
in Windows/DDEML that shows up when sending a
command from a Unicode DDE client to an ANSI DDE server.
The previous commands have all been for acting as as DDE client. The
listen command however is for acting as a DDE server. Its use is
intended for testing DDE clients as it just logs the interactions made by a DDE
client with it, e.g.
C:\> ddecmd listen -s TestServer XTYP_CONNECT: 'TestServer', 'TestTopic' XTYP_CONNECT_CONFIRM: 'TestServer', 'TestTopic' XTYP_REQUEST: 'TestServer', 'TestTopic', 'TestItem', '1' XTYP_DISCONNECT: 'TestServer', 'TestTopic' <CTRL+C>
The only additional switch supported is
--delay which causes the
DDE server to pause before replying to simulate a slow-running server.
This command is not a native DDE transaction type but a hybrid that combines the XTYP_ADVSTART and XTYP_REQUEST transactions to request a value in much the same way as Excel links to data. The delay between the two DDE transactions is configurable but defaults to 0 ms.
C:\> ddecmd fetch -s excel -t [book1]sheet1 -i R1C1
Note: This command was added specifically to cater for the MetaTrader DDE Server which fails an XTYP_REQUEST with N/A unless an XTYP_ADVSTART has already been invoked on the item.
The default timeout for any DDE transaction is set to 30,000 ms (30 secs). If
your DDE server is slow at returning responses you might receive one of the DDE
timeout errors -
etc. You can increase the timeout for any transaction (except the
command) with the
--timoeut switch, e.g.
C:\> ddecmd execute -s excel -t [book1]sheet1 -c "[App.Minimize]" --timeout 60000
The table below lists the common formats (i.e. text based) that you can request
The table below lists the variables can be used within the
switch. To include a '%' character in the output you need to escape it with
another '%', just as you would in a batch file, e.g. '%%'. All other characters
in the string are output verbatim.
|%s||The name of the DDE service|
|%t||The name of the DDE topic|
|%i||The name of the DDE item|
|%v||The value of the DDE item|
|%d||The timestamp of when the value was received|
For example, if an advise loop is started for a link
--output-format specified as
"%d: (%s,%t,%i) = %v",
the output might look like this:-
2013-02-01 17:33:45: (SERVICE,TOPIC,ITEM) = 42.0
Note: If you are executing commands from within a batch file you need to
remember to escape the '%' characters with another '%'. So the example above
would then become
"%%d: (%%s,%%t,%%i) = %%v". That also means to
escape a single literal '%' in the format string would require the sequence
The '%d' variable that can be used in the
causes a timestamp to be output. As shown in the example above it defaults to
the ISO format "YYYY-MM-DD HH:MM:SS". However the format can be customized with
--time-format switches. The
format strings are effectively passed directly to the
Windows API functions. To avoid either the date or time being output at all
specify an empty format, e.g.
This table lists the place-holders that can be used in the date picture format.
|d||Day of month as digits with no leading zero for single-digit days|
|dd||Day of month as digits with leading zero for single-digit days|
|ddd||Day of week as a three-letter abbreviation|
|dddd||Day of week as its full name|
|M||Month as digits with no leading zero for single-digit months|
|MM||Month as digits with leading zero for single-digit months|
|MMM||Month as a three-letter abbreviation|
|MMMM||Month as its full name|
|y||Year as last two digits, but with no leading zero for years less than 10|
|yy||Year as last two digits, but with leading zero for years less than 10|
|yyyy||Year represented by full four digits|
This table lists the place-holders that can be used in the time picture format.
|h||Hours with no leading zero for single-digit hours; 12-hour clock|
|hh||Hours with leading zero for single-digit hours; 12-hour clock|
|H||Hours with no leading zero for single-digit hours; 24-hour clock|
|HH||Hours with leading zero for single-digit hours; 24-hour clock|
|m||Minutes with no leading zero for single-digit minutes|
|mm||Minutes with leading zero for single-digit minutes|
|s||Seconds with no leading zero for single-digit seconds|
|ss||Seconds with leading zero for single-digit seconds|
|t||One character time-marker string, such as A or P|
|tt||Multi-character time-marker string, such as AM or PM|
This application is freeware - you get what you pay for, nothing more, nothing less.
The full source code (C++) is available from my web site listed below.
Using the --version switch will also display my contact details. Please check the web site for updates.
13th January 2017