xlAddInManagerInfo/xlAddInManagerInfo12

适用于:Excel 2013 | Office 2013 | Visual Studio

在 Excel 会话中首次调用外接程序管理器时由 Microsoft Excel 调用。 此函数用于向 Add-In 管理器提供有关加载项的信息。

Excel 2007 及更高版本调用 xlAddInManagerInfo12 ,如果 XLL 导出,则优先调用 xlAddInManagerInfoxlAddInManagerInfo12 函数的工作方式应与 xlAddInManagerInfo 相同,以避免 XLL 行为出现版本特定的差异。 Excel 要求 xlAddInManagerInfo12 返回 XLOPER12 数据类型,而 xlAddInManagerInfo 应返回 XLOPER

早于 Excel 2007 的 Excel 版本不调用 xlAddInManagerInfo12 函数,因为这些函数不支持 XLOPER12

Excel 不需要 XLL 来实现和导出其中任一函数。

LPXLOPER WINAPI xlAddInManagerInfo(LPXLOPER pxAction);
LPXLOPER12 WINAPI xlAddInManagerInfo12(LPXLOPER12 pxAction);

参数

pxAction:指向 xltypeIntxltypeNum) (数值 XLOPER/XLOPER12 的指针。

Excel 要求的信息。

属性值/返回值

如果 pxAction 是数字 1,或者可以强制使用数字 1,则此函数的实现应返回一个字符串,其中包含有关外接程序的一些信息,通常为加载项的名称和版本号。 否则,它应返回 #VALUE!。

如果不返回字符串,Excel 会尝试将返回的值转换为字符串。

备注

如果返回的字符串指向动态分配的缓冲区,则必须确保最终释放此缓冲区。 如果字符串是由 Excel 分配的,则通过设置 xlbitXLFree 来执行此操作。 如果字符串是由 DLL 分配的,则通过设置 xlbitDLLFree 来执行此操作,如果返回 XLOPER) 或 xlAutoFree12 (返回XLOPER12) ,还必须在 xlAutoFree (中实现。

示例

\SAMPLES\GENERIC\GENERIC.C

LPXLOPER12 WINAPI xlAddInManagerInfo12(LPXLOPER12 xAction)
{
    static XLOPER12 xInfo, xIntAction;
/*
** This code coerces the passed-in value to an integer. This is how the
** code determines what is being requested. If it receives a 1, it returns a
** string representing the long name. If it receives anything else, it
** returns a #VALUE! error.
*/
    Excel12f(xlCoerce, &xIntAction, 2, xAction, TempInt12(xltypeInt));
    if(xIntAction.val.w == 1) 
    {
        xInfo.xltype = xltypeStr;
        xInfo.val.str = L"\026Example Standalone DLL";
    }
    else 
    {
        xInfo.xltype = xltypeErr;
        xInfo.val.err = xlerrValue;
    }
// Word of caution - returning static XLOPERs/XLOPER12s is not thread safe
// for UDFs declared as thread safe. Use alternate memory allocation mechanisms.
    return (LPXLOPER12)&xInfo;
} 

另请参阅

加载项管理器和 XLL 接口函数