NewsArchive
12-05-2001, 12:00 AM
I am using the OLE Array to SafeArray code from the online help to generate
a pointer to a user defined structure.
The call is crashing.
ex:
string s1(128);
string s2(128);
typedef foo
begin
number n1;
number n2;
pointer p1;
pointer p2;
number n3;
end;
foo pointer pfoobar;
foo bar;
bar.p1 = &s1;
bar.p2 = &s2;
I pass bar to the function call below like so
pfoobar = ArrayToPointer(bar);
and pass the returned pointer to my function call in a dll.
wndows shuts down the setup when I make the call.
Any ideas???
then from the online help
/* Define a data structure that mirrors the safearray format. */
typedef _SAFEARRAY
begin
SHORT cDims;
SHORT fFeatures;
LONG cbElements;
LONG cLocks;
POINTER pvData;
end;
/* Define a data structure that mirrors the OLE Automation VARIANT format.
*/
typedef _VARIANT
begin
SHORT vt;
SHORT wReserved1;
SHORT wReserved2;
SHORT wReserved3;
NUMBER nData;
end;
prototype POINTER ArrayToPointer(BYREF VARIANT);
function POINTER ArrayToPointer(array)
_VARIANT POINTER pVariant;
_SAFEARRAY POINTER pArray;
begin
/* Cast a pointer to the array as an OLE VARIANT pointer. */
pVariant = &array;
/* Get a pointer to the safearray. */
pArray = pVariant->nData;
/* Return a pointer to the array data. */
return pArray->pvData;
end;
a pointer to a user defined structure.
The call is crashing.
ex:
string s1(128);
string s2(128);
typedef foo
begin
number n1;
number n2;
pointer p1;
pointer p2;
number n3;
end;
foo pointer pfoobar;
foo bar;
bar.p1 = &s1;
bar.p2 = &s2;
I pass bar to the function call below like so
pfoobar = ArrayToPointer(bar);
and pass the returned pointer to my function call in a dll.
wndows shuts down the setup when I make the call.
Any ideas???
then from the online help
/* Define a data structure that mirrors the safearray format. */
typedef _SAFEARRAY
begin
SHORT cDims;
SHORT fFeatures;
LONG cbElements;
LONG cLocks;
POINTER pvData;
end;
/* Define a data structure that mirrors the OLE Automation VARIANT format.
*/
typedef _VARIANT
begin
SHORT vt;
SHORT wReserved1;
SHORT wReserved2;
SHORT wReserved3;
NUMBER nData;
end;
prototype POINTER ArrayToPointer(BYREF VARIANT);
function POINTER ArrayToPointer(array)
_VARIANT POINTER pVariant;
_SAFEARRAY POINTER pArray;
begin
/* Cast a pointer to the array as an OLE VARIANT pointer. */
pVariant = &array;
/* Get a pointer to the safearray. */
pArray = pVariant->nData;
/* Return a pointer to the array data. */
return pArray->pvData;
end;