DdeGetData

3.1

  #include <ddeml.h>    

  DWORD DdeGetData(hData, pDest, cbMax, offSrc)    
  HDDEDATA hData; /* handle of global memory object */
  void FAR* pDest; /* address of destination buffer */
  DWORD cbMax; /* amount of data to copy */
  DWORD offSrc; /* offset to beginning of data */

The DdeGetData function copies data from the given global memory object to the specified local buffer.

Parameters

hData

Identifies the global memory object that contains the data to copy.

pDest

Points to the buffer that receives the data. If this parameter is NULL, the DdeGetData function returns the amount, in bytes, of data that would be copied to the buffer.

cbMax

Specifies the maximum amount, in bytes, of data to copy to the buffer pointed to by the pDest parameter. Typically, this parameter specifies the length of the buffer pointed to by pDest.

offSrc

Specifies an offset within the global memory object. Data is copied from the object beginning at this offset.

Return Value

If the pDest parameter points to a buffer, the return value is the size, in bytes, of the memory object associated with the data handle or the size specified in the cbMax parameter, whichever is lower.

If the pDest parameter is NULL, the return value is the size, in bytes, of the memory object associated with the data handle.

Errors

Use the DdeGetLastError function to retrieve the error value, which may be one of the following:

DMLERR_DLL_NOT_INITIALIZED
DMLERR_INVALID_HDDEDATA
DMLERR_INVALIDPARAMETER
DMLERR_NO_ERROR

Example

The following example copies data from a global memory object to a local buffer and then fills the TIME structure with data from the buffer:

HDDEDATA hData;
char szBuf[32];

typedef struct {
    int hour;
    int minute;
    int second;
} TIME;

DdeGetData(hData, (LPBYTE) szBuf, 32L, 0L);
sscanf(szBuf, "%d:%d:%d", &nTime.hour, &nTime.minute,
    &nTime.second);

See Also

DdeAccessData, DdeCreateDataHandle, DdeFreeDataHandle