Prev Next
The DdeCreateDataHandle function creates a dynamic data exchange (DDE)
object and fills the object with data from the specified buffer. A DDE
application uses this function during transactions that involve passing data
to the partner application.
HDDEDATA DdeCreateDataHandle(
DWORD idInst,
|
// instance identifier
|
LPBYTE pSrc,
|
// pointer to source buffer
|
DWORD cb,
|
// length of DDE object
|
DWORD cbOff,
|
// offset from beginning of source buffer
|
HSZ hszItem,
|
// handle to item name string
|
UINT wFmt,
|
// clipboard data format
|
UINT afCmd
|
// creation flags
|
);
|
|
Parameters
-
idInst
-
Specifies the application instance identifier obtained by a previous call to
the DdeInitialize function.
-
pSrc
-
Points to a buffer that contains data to be copied to the DDE object. If this
parameter is NULL, no data is copied to the object.
-
cb
-
Specifies the amount of memory, in bytes, to copy from the buffer pointed to
by pSrc. (include the terminating NULL, if the data is a string). If
this parameter is zero, the pSrc parameter is ignored.
-
cbOff
-
Specifies an offset, in bytes, from the beginning of the buffer pointed to by
the pSrc parameter. The data beginning at this offset is copied from
the buffer to the DDE object.
-
hszItem
-
Identifies the string that specifies the data item corresponding to the DDE
object. This handle must have been created by a previous call to the DdeCreateStringHandle
function. If the data handle is to be used in an XTYP_EXECUTE transaction,
this parameter must be 0L.
-
wFmt
-
Specifies the standard clipboard format of the data.
-
afCmd
-
Specifies the creation flags. This parameter can be HDATA_APPOWNED, which
specifies that the server application calling the DdeCreateDataHandle
function owns the data handle this function creates. This flag enables the
application to share the data handle with other Dynamic Data Exchange
Management Library (DDEML) applications rather than creating a separate handle
to pass to each application. If this flag is specified, the application must
eventually free the shared memory object associated with the handle by using
the DdeFreeDataHandle function. If
this flag is not specified, the handle becomes invalid in the application that
created the handle after the data handle is returned by the application’s DDE
callback function or is used as a parameter in another DDEML function.
Return Values
If the function succeeds, the return value is a data handle.
If the function fails, the return value is 0L.
Errors
The DdeGetLastError function can be
used to get the error code, which may be one of the following values:
DMLERR_DLL_NOT_INITIALIZED
DMLERR_INVALIDPARAMETER
DMLERR_MEMORY_ERROR
DMLERR_NO_ERROR
Remarks
Any unfilled locations in the DDE object are undefined.
After a data handle has been used as a parameter in another DDEML function or
has been returned by a DDE callback function, the handle may be used only for
read access to the DDE object identified by the handle.
See Also
DdeAccessData, DdeCreateStringHandle,
DdeFreeDataHandle, DdeGetData,
DdeInitialize