DDEInitiate( ) Function

Example   See Also

Establishes a dynamic data exchange (DDE) channel between Visual FoxPro and another Microsoft Windows-based application.

Syntax

DDEInitiate(cServiceName, cTopicName)

Returns

Numeric

Arguments

cServiceName

Specifies the service name of the server application which, in most cases, is the name of the executable file without its extension. The default service name for Visual FoxPro is Visual FoxPro. If you are establishing a channel to Microsoft Excel, cServiceName is Excel.

cTopicName

Specifies the topic name. The topic is application-specific and must be understood by the application. For example, one topic supplied by most DDE servers is the System topic. See the application documentation for the service and topic names supported by the application.

Remarks

DDEInitiate( ) establishes a DDE channel between Visual FoxPro and a DDE server application. Once a channel is established, Visual FoxPro can request data from the server by referring to the channel in subsequent DDE functions. Visual FoxPro acts as the client, requesting data from the server application through the channel.

If the channel is successfully established, DDEInitiate( ) returns the channel number. Channel numbers are non-negative, and the number of channels you can establish is limited only by your system resources.

DDEInitiate( ) returns –1 if the channel cannot be established. If the server application isn't open, Visual FoxPro asks if you would like to open it. If you choose Yes, Visual FoxPro attempts to open the application. (You can use DDELastError( ) to determine why a channel cannot be established.)

To avoid being asked whether you want to open the application, set the DDESetOption( ) SAFETY option. You can also use RUN with the /N option to start the application.

A channel can be closed with DDETerminate( ).