zoukankan      html  css  js  c++  java
  • 【XLL API 函数】xlStack

    查看堆栈区还剩余多少空间

    原型

    Excel12(xlStack, LPXLOPER12 pxRes, 0);
    

    参数

    此函数没有带任何参数

    属性值/返回值

    返回堆栈区还剩余的字节数

    备注

    返回最新版本的可用堆栈空间总量,包含 Excel 2007 溢出的 16 位整型 XLOPER。这表示当调用 XLOPER 使用 Excel4Excel4vxlStack 可以返回 32767 和 32768 。为了获取正确值,你必需把返回值转换为 unsigned short。

    在Excel 2007中,你需要使用 XLOEPR12 和 Excel12 或 Excel12v 调用这个函数,在这种情况下,返回值是 堆栈可用的内存数量,或64KB,以较小者为准。

    Excel 在堆栈区只有有限的空间,你要小心处理避免超出内存限制。千万不要往栈区放入过大的数据结构,尽量将本地变量声明为静态。避免递归调用函数,因它他们将很快填满堆栈。

    如果你担心栈区溢出,可以通过频繁调用此函数检查剩余空间。

    实例

    The first example displays an alert message containing the amount of stack space left and is contained in SAMPLESEXAMPLEEXAMPLE.C. The second example does the same thing, working with XLOPERs and is not contained in the SDK example code.

    第一个实例会显示一个警告对话框,内部包含了剩余的堆栈空间,实例包含在 SAMPLESEXAMPLEEXAMPLE.C,第二个实例使用 XLOPER 做同样的事,不过这个实例没有包含在SDK的实例代码中

    short WINAPI xlStackExample(void)
    {
       XLOPER12 xRes;
    
       Excel12(xlStack, &xRes, 0);
       Excel12(xlcAlert, 0, 1, (LPXLOPER12)&xRes);
       return 1;
    } 
    
    short int WINAPI xlStackExample_XLOPER(void)
    {
        XLOPER xRes;
    
        Excel4(xlStack, (LPXLOPER)&xRes, 0);
        xRes.xltype = xltypeNum; // Change the type to double
        // Cast to an unsigned short to get rid of the overflow problem
        xRes.val.num = (double)(unsigned short) xRes.val.w;
        Excel4(xlcAlert, 0, 1, (LPXLOPER)& xRes);
        return 1;
    }
    
  • 相关阅读:
    【逆序对】N*M Puzzle / Simple Puzzle
    【逆序对】Ultra
    bzoj 1814 Fornula 1
    hdu 1693 插头dp入门
    bzoj 2154
    没有上司的舞会
    【HNOI】合唱队
    luogu 自适应Simpson2
    luogu 自适应Simpson1
    【bzoj 1502】月下柠檬树
  • 原文地址:https://www.cnblogs.com/boluoke/p/5984166.html
Copyright © 2011-2022 走看看