xlGetInst

This function returns the instance handle of the instance of Microsoft Excel that is currently calling a DLL.

The instance handle (xltypeInt) will be in the val.w field.

Syntax

Excel4(xlGetInst, LPXLOPER pxRes, 0);

This function has no arguments.

Remarks

This function can be used to distinguish between multiple running instances of Microsoft Excel that are calling the DLL.

Example

The following example compares the instance of the last copy of Microsoft Excel that called it to the current copy of Microsoft Excel that called it. If they are the same, it returns 1; if not, it returns 0.

\SAMPLES\EXAMPLE\EXAMPLE.C

short WINAPI xlGetInstExample(void)
{
    XLOPER xRes;
    static HANDLE hOld = 0;
    int iRet;

    Excel4(xlGetInst, (LPXLOPER)&xRes, 0);

    if((unsigned int)xRes.val.w != hOld)
        iRet = 0;
    else
        iRet = 1;

    hOld = xRes.val.w;

    return iRet;
}

Related Function

xlGetHwnd