During development, we often encounter the need to transmit structures or multiple variables. To adapt to the transmission of Multiple Data Structure Variables, Microsoft defined the safearray variable. For this reason, I have studied this variable, share with netizens.
Essentially, safearray adds a descriptor to a common array, indicating its dimension, length, boundary, element type, and other information.
I. Definition
Typedef struct tagsafearraybound
{
Ulong celements;
Long llbound;
} Safearraybound;
Typedef struct tagsafearray
{
Ushort cdims;
Ushort ffeatures;
Ulong cbelements;
Ulong clocks;
Pvoid pvdata;
Safearraybound rgsabound [1];
} Safearray;
Ii. operation API
/*---------------------------------------------------------------------*/
/* Safearray API */
/*---------------------------------------------------------------------*/
Winoleautapi safearrayallocdescriptor (uint cdims, safearray ** ppsaout );
Winoleautapi safearrayallocdescriptorex (vartype VT, uint cdims, safearray ** ppsaout );
Winoleautapi safearrayallocdata (safearray * PSA );
Winoleautapi _ (safearray *) safearraycreate (vartype VT, uint cdims, safearraybound * rgsabound );
Winoleautapi _ (safearray *) safearraycreateex (vartype VT, uint cdims, safearraybound * rgsabound, pvoid pvextra );
Winoleautapi safearraycopydata (safearray * psasource, safearray * psatarget );
Winoleautapi safearraydestroydescriptor (safearray * PSA );
Winoleautapi safearraydestroydata (safearray * PSA );
Winoleautapi safearraydestroy (safearray * PSA );
Winoleautapi safearrayredim (safearray * PSA, safearraybound * psaboundnew );
Winoleautapi _ (uint) safearraygetdim (safearray * PSA );
Winoleautapi _ (uint) safearraygetelemsize (safearray * PSA );
Winoleautapi safearraygetubound (safearray * PSA, uint Ndim, long * plubound );
Winoleautapi safearraygetlbound (safearray * PSA, uint Ndim, long * pllbound );
Winoleautapi safearraylock (safearray * PSA );
Winoleautapi safearrayunlock (safearray * PSA );
Winoleautapi safearrayaccessdata (safearray * PSA, void hugep ** ppvdata );
Winoleautapi safearrayunaccessdata (safearray * PSA );
Winoleautapi safearraygetelement (safearray * PSA, long * rgindices, void * PV );
Winoleautapi safearrayputelement (safearray * PSA, long * rgindices, void * PV );
Winoleautapi safearraycopy (safearray * PSA, safearray ** ppsaout );
Winoleautapi safearrayptrofindex (safearray * PSA, long * rgindices, void ** ppvdata );
Winoleautapi safearraysetrecordinfo (safearray * PSA, irecordinfo * prinfo );
Winoleautapi safearraygetrecordinfo (safearray * PSA, irecordinfo ** prinfo );
Winoleautapi safearraysetiid (safearray * PSA, refguid guid );
Winoleautapi safearraygetiid (safearray * PSA, guid * pguid );
Winoleautapi safearraygetvartype (safearray * PSA, vartype * PVT );
Winoleautapi _ (safearray *) safearraycreatevector (vartype VT, long llbound, ulong celements );
Iii. Use
4. nagging, since csdn was unable to be opened during the Olympics that few days ago, it was originally written for a long time and has never been made public, and has not been updated during this period, later, I wrote it slowly.