Has anybody samples of using SAFEARRAY in assembly programs?
A SAFEARRAY is an automation (or COM or ActiveX) data type. SAFEARRAY is a structure for storing arrays of arbitrary complexity. Not only does it allow multidimensional arrays, but it provides a SAFEARRAYBOUND instance for each dimension to describe the starting index (unlike C++ arrays, SAFEARRAYs don't have to be zero-based) and number of elements. The SAFEARRAY and SafeArrayXXXX COM runtime methods are documented in the Automation Programmer's Guide. I've not seen any asm code on it, but MSDN has lots of C code defining how to declare and manipulate one. Basically, stick to the provided API's to work with these beasts, don't try to manipulate them directly or one day your code might break.
Ernie, thank you very much! Visual Basic allows to use dinamic arrays. For example:
How can I do the same in my assembly program? I think VB uses SafeArray... functions.
Dim intValue() As Integer Dim i as Integer i = 10 Redim Preserve intValue(i)
I don't know anything about SAFEARRAYs, but if you just want to use dynamic arrays, allocate the memory needed for the array with GlobalAlloc, then when you want to redefine the array, use GlobalReAlloc to change the size of the allocated memory block. Thomas
vkim, I took the liberty of emailing you some Safearray info. I found an article in this area of MSDN most helpful with dealing with BSTR's. Anyone else interested, either post your email here or email me direct. ----------------------------- "The only danger in space is if we land on the terrible Planet of the Apes...wait a minute...Statue of Liberty ... that was our planet! You maniacs! You blew it up! Damn you! Damn you all to hell!"
Thanks again! It's a very useful article. And I very love Bruce McKinney's writings, especially his book "Hardcore Visual Basic". Thanks a lot!