Listing 2 用来告诉VB编译怎样调用我们的函数指针的外部ODL文件。没有对这个接口的描述,我们虽仍能生成代理到正确函数指针的COM对象作者: LucasLynn 时间: 2005-8-28 08:54
How VB Allocates Fixed-Size Arrays <TR align=left bgColor=#ffffcc>You might think the entire array is being created as a local variable on the stack when you allocate a fixed-sized array in VB (I did). This is only a half-truth. The array descriptor, a structure that describes an array抯 size and type, is placed on the stack like any other local variable. However, the array抯 data is allocated on the heap. If you want a fully stack-allocated array, you need to embed your fixed-size array in a user-defined type (UDT) and use a local variable typed as the UDT, not as a fixed-size array. The reason for these allocation semantics is that the 64K size restriction on embedded fixed-size arrays does not apply to nonembedded fixed-size arrays, but the 64K limit does apply to the total size of local variables. Similar semantics apply to a module-level fixed-size array, except that embedded fixed-size arrays are allocated with the module instead of on the stack. You should take the precaution of defining all vtables as fixed-size arrays in a UDT to protect against the case where an object is still pointing at a function delegator structure when VB is tearing the process down. During teardown, VB clears all heap-allocated variables (objects, arrays, strings) in all modules before releasing the memory allocated for each specific module. Your tear-down code is dependent on the ordering of your modules in the VBP file if your vtable is heap-allocated, and you don抰 have to worry about custom vtables vaporizing beneath your objects or disappearing during tear-down if you define any custom vtable in an embedded fixed-size array. 作者: LucasLynn 时间: 2005-8-28 08:55 本文的附图: