ATL Internals 2ed复习.chapter 3.SAFEARRAY
来源:互联网 发布:淘宝改标题影响权重 编辑:程序博客网 时间:2024/06/06 05:11
A Review of the COM SAFEARRAY Data Type
为了在COM函数间传递Array参数,IDL定义了SAFEARRAY类型:
interface IMyInterface : IUnknown { HRESULT GetArray([out,retval] SAFEARRAY(VARIANT_BOOL)* myArray);};
typedef struct tagSAFEARRAY { USHORT cDims; USHORT fFeatures; ULONG cbElements; ULONG cLocks; PVOID pvData; SAFEARRAYBOUND rgsabound[ 1 ];} SAFEARRAY;
其中
cDims数组的维数
cbElements每一个元素的size
pvData指向真实数据
SAFEARRAYBOUND用于规定上下限:rgsabound[0]用于规定最左维,rgsabound[cDims-1]规定最右维
typedef struct tagSAFEARRAYBOUND { ULONG cElements; LONG lLbound; } SAFEARRAYBOUND;
创建Array例子:
SAFEARRAYBOUND rgsabound[2];rgsabound[0].cElements = 3;rgsabound[0].lLbound = 0;rgsabound[1].cElements = 4;rgsabound[1].lLbound = 0;
SAFEARRAY* psa = ::SafeArrayCreate(VT_R8, 2, rgsabound);
读取Array中数据例子:
long rgIndices[] = { 2, 1 };double lElem;::SafeArrayGetElement(psa, rgIndices, (void*)&lElem);
注意上面例子取得[1][2]的数据,
销毁Array应该使用:
::SafeArrayDestroy(psa);
- ATL Internals 2ed复习.chapter 3.SAFEARRAY
- ATL Internals 2ed复习.chapter 3.ATL Memory Managers
- ATL Internals 2ed复习.chapter 2
- ATL Internals 2ed复习.chapter 3.CComVariant
- ATL Internals 2ed复习.chapter 3.CComSafeArray
- ATL Internals 2ed复习.chapter 3.CComPtr CComQIPtr
- ATL Internals 2ed复习.chapter 3.CComGITPtr
- ATL Internals 2ed复习.chapter 3.CAutoPtr
- ATL Internals 2ed复习.chapter 7.ATL Persistence implements
- ATL Internals 2ed复习.chapter 4.Thread
- ATL Internals 2ed复习.chapter 4.IUnknown
- ATL Internals 2ed复习.chapter 4.Creators
- ATL Internals 2ed复习.chapter 4.Debugging
- ATL Internals 2ed复习.chapter 5.COM Server review
- ATL Internals 2ed复习.chapter 5.Object Map
- ATL Internals 2ed复习.chapter 5.CAtlModule
- ATL Internals 2ed复习.chapter 6.Table driven QueryInterface
- ATL Internals 2ed复习.chapter 6.interface map tricks
- arm7 力天电子lpc2148 GPIO之一蜂鸣器试验程序
- 【Tiny6410 And Linux】—(6.1)—LCD 驱动测试程序——代码
- Magic.DVD.Copier.v7.1.1-LAXiTY
- Madcrosoft.PC.TuneUp.Tools.2012.v8.0.043-LAXiTY
- ListView的样式设计与应用
- ATL Internals 2ed复习.chapter 3.SAFEARRAY
- Aneesoft.HD.Video.Converter.v3.5.0.0-LAXiTY
- java操作excel
- aspf
- 暖气的各种材质、和适用范围
- HDU 4411
- Silverlight中Datagrid添加Button列用于控制单行对象
- 如何选择暖气片
- android获取屏幕尺寸、密度(判断手机屏幕类型)