6.6.1 Client Applications and Direct Use of Dynamic Data Exchange

When opening a link or an embedded document, the client application should look up the class name in the registration database, as described in Section 6.2.6, “Registration.”

The following pseudocode illustrates the chain of events for a client implementing OLE through DDE. Whenever a client that attempts to establish a conversation with a server receives responses from more than one server, the client should accept the first server and reject the others.

Linked object:

WM_DDE_INITIATE class name, document name
if not found {
WM_DDE_INITIATE class name, OLESystem
if not found {
WM_DDE_INITIATE class name, System
if not found {
launch application name, /Embedding
fLaunched = true
WM_DDE_INITIATE class name, OLESystem
if not found {
WM_DDE_INITIATE class name, System
if not found
return error
}
}
}

/*
* Now there is a conversation with the server on the System or
* OLESystem topic.
*/

WM_DDE_EXECUTE StdOpenDocument(DocumentName)
WM_DDE_INITIATE class name, document name
if not found {
if(fLaunched) WM_DDE_EXECUTE StdExit /* clean up */
return error
}
}

/*
* Now there is a conversation with the correct document.
*/

Embedded object:

WM_DDE_INITIATE class name, OLESystem
if not found {
WM_DDE_INITIATE class name, System
if not found {
launch application name, /Embedding
fLaunched = true
WM_DDE_INITIATE class name, OLESystem
if not found {
WM_DDE_INITIATE class name, System
if not found
return error
}
}
}

/*
* Now there is a conversation with the server on the system or
* OLESystem topic.
*/

DDE_EXECUTE StdEditDocument(DocumentName)

/*
* Or StdCreateDoc if this is an Insert Object command
*/

WM_DDE_INITIATE class name, document name
if not found {
if(fLaunched) DDE_EXECUTE StdExit /* clean up */
return error
}

/* Now there is a conversation with the correct document. */