Professional Excel Development [Electronic resources] : The Definitive Guide to Developing Applications Using Microsoft® Excel and VBA® نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional Excel Development [Electronic resources] : The Definitive Guide to Developing Applications Using Microsoft® Excel and VBA® - نسخه متنی

Stephen Bullen, Rob Bovey, John Green

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











XLOPERs and Memory Management


Excel allocates and frees any arguments passed to a custom worksheet function. For most XLOPER return values, you pass Excel a static XLOPER variable. Your XLL must allocate any arguments passed to the Excel4 function. When a call to the Excel4 function returns an XLOPER containing a pointer, that memory is allocated and managed by Excel. You must call the xlFree function on that XLOPER so Excel can free its memory. You can safely call xlFree on every return value from the Excel4 function. Calling xlFree on an XLOPER that does not contain a pointer does nothing, and if xlFree is called twice on the same XLOPER Excel ignores the second call.

Excel supports two special memory management bits in the xltype field of the XLOPER data type. If you need to use an XLOPER as the return value of a worksheet function, but that XLOPER itself was returned from Excel via the Excel4 function, you set the xlbitXLFree bit in the xltype field of the XLOPER. When you do this, Excel copies out the data it needs and then frees the XLOPER for you, relieving you of the requirement to call xlFree on the XLOPER.

Similarly, if you set the xlbitDLLFree bit in the xltype field of an XLOPER, Excel copies the data it requires out of the XLOPER and then calls the xlAutoFree function in your XLL, passing it a pointer to the XLOPER. Your XLL can then free any memory it allocated for this XLOPER. This is useful for returning large amounts of data to Excel without being required to have the memory for it remain allocated indefinitely.

NOTE

Do not modify any XLOPER managed by Excel. This includes worksheet function arguments and return values from the Excel4 function. Copy the data into your own memory area if you need to work with it. Remember that Excel does not use null-terminated C strings, so if you copy a string value from an XLOPER returned by Excel you must copy it character by character into a new char array for the number of characters specified in the first byte of the XLOPER string.


/ 225