Has anybody samples of using SAFEARRAY in assembly programs?
Posted on 2001-04-16 01:24:00 by vkim
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.
Posted on 2001-04-16 07:23:00 by Ernie
Ernie, thank you very much! Visual Basic allows to use dinamic arrays. For example:

Dim intValue() As Integer
Dim i as Integer
i = 10
Redim Preserve intValue(i)
How can I do the same in my assembly program? I think VB uses SafeArray... functions.
Posted on 2001-04-16 07:59:00 by vkim
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
Posted on 2001-04-16 13:12:00 by 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!"
Posted on 2001-04-16 23:12:00 by Ernie
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!
Posted on 2001-04-16 23:45:00 by vkim