xlfRegister

xlfRegister is the core Excel C API function that registers an XLL function or command with Excel.
It tells Excel what the function is, how to call it, what types it uses, and how it should appear in the Function Wizard.

int Excel12(int iFunction, 
            xloper12 *pxReturnValue,
            int iCount,
            xloper12 *pxDLLModuleName,
            xloper12 *pxFunctionName,
            xloper12 *pxTypeText,
            xloper12 *pxWorksheetFunctionName,
            xloper12 *pxArgumentText,
            xloper12 *pxMacroType,
            xloper12 *pxCategory,
            xloper12 *pxShortcutText,
            xloper12 *pxHelpTopic,
            xloper12 *pxFunctionHelp,
            xloper12 *pxArgument1,
            xloper12 *pxArgument2,
            ..)

iFunction - The number corresponding to a pre-defined function or command. xlfRegister
pxReturnValue - A pointer that will hold the result
iCount - The number of arguments that are being passed in
pxDLLModuleName - The full drive, path and filename of the DLL containing the function.
pxFunctionName - The name of the function as it is exported (case sensitive)
pxTypeText - The return data type and argument data types and calling permission string.
pxWorksheetFunctionName - The name of the function to call from Excel (case sensitive)
pxArgumentText - (Optional) Argument names as a comma-delimited concatenated string. Displayed in the Function Arguments dialog box
pxMacroType - (Optional) Whether a function or command. 1 or missing = Function. 2 = Command
pxCategory - (Optional) The category in which the function is to be listed. If missing the default is User Defined
pxShortcutText - (Optional) Not used (pass xltypeNil or xltypeMissing)
pxHelpTopic - (Optional) The help topic
pxFunctionHelp - (Optional) A brief description of the function. Displayed in the Insert Function dialog box
pxArgument1 - (Optional) Argument descriptions for each argument
pxArgument2 - (Optional) Argument descriptions for each argument


Example

Excel12f(xlfRegister, 
    0,
    11,
    (LPXLOPER12)&xDLL, // DLL name
    TempStr12(L"AddTwo"), // Procedure name (exported)
    TempStr12(L"BB"), // Type string: B = double return, B = double arg, B = double arg
    TempStr12(L"AddTwo"), // Function name in Excel
    TempStr12(L"x,y"), // Argument names
    TempInt12(1), // Macro type: 1 = worksheet function
    TempStr12(L"Math"), // Category
    TempStr12(L""), // Shortcut (commands only)
    TempStr12(L""), // Help topic
    TempStr12(L"Adds two numbers"), // Function help
    TempStr12(L"x: first number\ny: second number") // Argument help
);

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext