#include <ddeml.h> |
BYTE FAR* DdeAccessData(hData, lpcbData) | |||||
HDDEDATA hData; | /* handle of global memory object | */ | |||
DWORD FAR* lpcbData; | /* pointer to variable that receives data length | */ |
The DdeAccessData function provides access to the data in the given global memory object. An application must call the DdeUnaccessData function when it is finished accessing the data in the object.
hData
Identifies the global memory object to access.
lpcbData
Points to a variable that receives the size, in bytes, of the global memory object identified by the hData parameter. If this parameter is NULL, no size information is returned.
The return value points to the first byte of data in the global memory object if the function is successful. Otherwise, the return value is NULL.
Use the DdeGetLastError function to retrieve the error value, which may be one of the following:
DMLERR_DLL_NOT_INITIALIZED
DMLERR_INVALIDPARAMETER
DMLERR_NO_ERROR
If the hData parameter has not been passed to a Dynamic Data Exchange Management Library (DDEML) function, an application can use the pointer returned by DdeAccessData for read-write access to the global memory object. If hData has already been passed to a DDEML function, the pointer can only be used for read-only access to the memory object.
The following example uses the DdeAccessData function to obtain a pointer to a global memory object, uses the pointer to copy data from the object to a local buffer, then frees the pointer:
HDDEDATA hData;
LPBYTE lpszAdviseData;
DWORD cbDataLen;
DWORD i;
char szData[128];
lpszAdviseData = DdeAccessData(hData, &cbDataLen);
for (i = 0; i < cbDataLen; i++)
szData[i] = *lpszAdviseData++;
DdeUnaccessData(hData);
DdeAddData, DdeCreateDataHandle, DdeFreeDataHandle, DdeGetLastError, DdeUnaccessData