xlfUnregister(窗体 1)
适用于:Excel 2013 | Office 2013 | Visual Studio
可以从 Microsoft Excel 本身调用的 DLL 或 XLL 命令调用。 这等效于从 Excel XLM 宏表调用 UNREGISTER 。
xlfUnregister 可以两种形式调用:
表单 1:注销单个命令或函数。
表单 2:卸载并停用 XLL。
在表单 1 中调用此函数可减少以前使用 xlfRegister 或 REGISTER 注册的 DLL 函数或命令的使用计数。 如果使用情况计数已为零,则此函数无效。 当 DLL 中所有函数的使用计数为零时,将从内存中卸载 DLL。
xlfRegister (Form 1) 还定义了一个隐藏名称,该名称是函数文本参数 pxFunctionText,其计算结果为函数或命令的注册 ID。 注销函数时,应使用 xlfSetName 删除此名称,以便函数向导不再列出函数名称。 有关详细信息,请参阅 Excel XLL 开发中的已知问题。
Excel4(xlfUnregister, LPXLOPER pxRes, 1, LPXLOPER pxRegisterId);
参数
pxRegisterId (xltypeNum)
要注销的函数的注册 ID。
属性值/返回值
如果成功,则返回 TRUE (xltypeBool) ,否则返回 FALSE。
备注
首次注册函数时, xlfRegister 返回函数的注册 ID。 也可以通过调用 xlfRegisterId 函数 或 xlfEvaluate 函数来获取它。 请注意,如果尚未注册函数,则 xlfRegisterId 会尝试注册该函数。 因此,如果只是尝试获取 ID 以便注销函数,最好通过将注册的名称传递给 xlfEvaluate 来获取它。 如果尚未注册函数, xlfEvaluate 会失败并 #NAME?错误。
示例
请参阅 中的 \SAMPLES\GENERIC\GENERIC.C
fExit 函数的代码。
int WINAPI fExit(void)
{
XLOPER12 xDLL, // The name of this DLL //
xFunc, // The name of the function //
xRegId; // The registration ID //
int i;
//
// This code gets the DLL name. It then uses this along with information
// from g_rgFuncs[] to obtain a REGISTER.ID() for each function. The
// register ID is then used to unregister each function. Then the code
// frees the DLL name and calls xlAutoClose.
//
// Make xFunc a string //
xFunc.xltype = xltypeStr;
Excel12f(xlGetName, &xDLL, 0);
for (i = 0; i < g_rgWorksheetFuncsRows; i++)
{
xFunc.val.str = (LPWSTR) (g_rgWorksheetFuncs[i][0]);
Excel12f(xlfRegisterId,&xRegId,2,(LPXLOPER12)&xDLL,(LPXLOPER12)&xFunc);
Excel12f(xlfUnregister, 0, 1, (LPXLOPER12) &xRegId);
}
for (i = 0; i < g_rgCommandFuncsRows; i++)
{
xFunc.val.str = (LPWSTR) (g_rgCommandFuncs[i][0]);
Excel12f(xlfRegisterId,&xRegId,2,(LPXLOPER12)&xDLL,(LPXLOPER12)&xFunc);
Excel12f(xlfUnregister, 0, 1, (LPXLOPER12) &xRegId);
}
Excel12f(xlFree, 0, 1, (LPXLOPER12) &xDLL);
return xlAutoClose();
}