xlGetBinaryName

Used to return a handle for data saved by the xlDefineBinaryName function. Data with a defined binary name is saved with the workbook, and can be accessed by name at any time.

Syntax

Excel4(xlGetBinaryName, LPXLOPER pxRes, 1, LPXLOPER pxName);

pxRes

Bigdata XLOPER. When the function returns, the hdata member of the XLOPER contains a handle for the named data.

pxName

String XLOPER specifying the name of the data.

Microsoft Excel owns the memory handle returned in hdata. In Microsoft Windows, the handle is a global memory handle (allocated by the GlobalAlloc function).

Example

This example accepts a name and the address of a pointer. It uses the xlGetBinaryName function to retrieve a handle for the named data, and then locks the handle and returns the locked pointer at the passed-in address.

int WINAPI xlGetBinaryNameExample(LPSTR lpszName,
    LPBYTE *lpbData)
{
    int iRet;
    char stBuf[255];
    XLOPER xName, xData;

    lstrcpy(stBuf + 1, lpszName);
    stBuf[0] = lstrlen(lpszName);

    xName.xltype = xltypeStr;
    xName.val.str = stBuf;

    if ((iRet = Excel4(xlGetBinaryName, (LPXLOPER)&xData, 1,
            (LPXLOPER)&xName)) != xlretSuccess)
        return iRet;
    *lpbData = GlobalLock(xData.val.bigdata.h.hdata);

    return iRet;
}

Related Function

xlDefineBinaryName