DdeClientTransaction function (ddeml.h)
Begins a data transaction between a client and a server. Only a Dynamic Data Exchange (DDE) client application can call this function, and the application can use it only after establishing a conversation with the server.
HDDEDATA DdeClientTransaction(
[in, optional] LPBYTE pData,
[in] DWORD cbData,
[in] HCONV hConv,
[in, optional] HSZ hszItem,
[in] UINT wFmt,
[in] UINT wType,
[in] DWORD dwTimeout,
[out, optional] LPDWORD pdwResult
);
[in, optional] pData
Type: LPBYTE
The beginning of the data the client must pass to the server.
Optionally, an application can specify the data handle (HDDEDATA) to pass to the server and in that case the cbData parameter should be set to -1. This parameter is required only if the wType parameter is XTYP_EXECUTE or XTYP_POKE. Otherwise, this parameter should be NULL.
For the optional usage of this parameter, XTYP_POKE transactions where pData is a data handle, the handle must have been created by a previous call to the DdeCreateDataHandle function, employing the same data format specified in the wFmt parameter.
[in] cbData
Type: DWORD
The length, in bytes, of the data pointed to by the pData parameter, including the terminating NULL, if the data is a string. A value of -1 indicates that pData is a data handle that identifies the data being sent.
[in] hConv
Type: HCONV
A handle to the conversation in which the transaction is to take place.
[in, optional] hszItem
Type: HSZ
A handle to the data item for which data is being exchanged during the transaction. This handle must have been created by a previous call to the DdeCreateStringHandle function. This parameter is ignored (and should be set to 0L) if the wType parameter is XTYP_EXECUTE.
[in] wFmt
Type: UINT
The standard clipboard format in which the data item is being submitted or requested.
If the transaction specified by the wType parameter does not pass data or is XTYP_EXECUTE, this parameter should be zero.
If the transaction specified by the wType parameter references non-execute DDE data ( XTYP_POKE, XTYP_ADVSTART, XTYP_ADVSTOP, XTYP_REQUEST), the wFmt value must be either a valid predefined (CF_) DDE format or a valid registered clipboard format.
[in] wType
Type: UINT
The transaction type. This parameter can be one of the following values.
Value | Meaning |
---|---|
|
Begins an advise loop. Any number of distinct advise loops can exist within a conversation. An application can alter the advise loop type by combining the XTYP_ADVSTART transaction type with one or more of the following flags:
|
|
Ends an advise loop. |
|
Begins an execute transaction. |
|
Begins a poke transaction. |
|
Begins a request transaction. |
[in] dwTimeout
Type: DWORD
The maximum amount of time, in milliseconds, that the client will wait for a response from the server application in a synchronous transaction. This parameter should be TIMEOUT_ASYNC for asynchronous transactions.
[out, optional] pdwResult
Type: LPDWORD
A pointer to a variable that receives the result of the transaction. An application that does not check the result can use NULL for this value. For synchronous transactions, the low-order word of this variable contains any applicable DDE_ flags resulting from the transaction. This provides support for applications dependent on DDE_APPSTATUS bits. It is, however, recommended that applications no longer use these bits because they may not be supported in future versions of the Dynamic Data Exchange Management Library (DDEML). For asynchronous transactions, this variable is filled with a unique transaction identifier for use with the DdeAbandonTransaction function and the XTYP_XACT_COMPLETE transaction.
Type: HDDEDATA
If the function succeeds, the return value is a data handle that identifies the data for successful synchronous transactions in which the client expects data from the server. The return value is nonzero for successful asynchronous transactions and for synchronous transactions in which the client does not expect data. The return value is zero for all unsuccessful transactions.
The DdeGetLastError function can be used to get the error code, which can be one of the following values:
When an application has finished using the data handle returned by DdeClientTransaction, the application should free the handle by calling the DdeFreeDataHandle function.
Transactions can be synchronous or asynchronous. During a synchronous transaction, DdeClientTransaction does not return until the transaction either completes successfully or fails. Synchronous transactions cause a client to enter a modal loop while waiting for various asynchronous events. Because of this, a client application can still respond to user input while waiting on a synchronous transaction, but the application cannot begin a second synchronous transaction because of the activity associated with the first. DdeClientTransaction fails if any instance of the same task has a synchronous transaction already in progress.
During an asynchronous transaction, DdeClientTransaction returns after the transaction has begun, passing a transaction identifier for reference. When the server's DDE callback function finishes processing an asynchronous transaction, the system sends an XTYP_XACT_COMPLETE transaction to the client. This transaction provides the client with the results of the asynchronous transaction that it initiated by calling DdeClientTransaction. A client application can choose to abandon an asynchronous transaction by calling the DdeAbandonTransaction function.
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | ddeml.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
Conceptual
Dynamic Data Exchange Management Library
Reference