如何使用SafeArrayPutElement使用双数据类型值填充SafeArray [英] How to fill the SafeArray with double datatype values using SafeArrayPutElement

查看:125
本文介绍了如何使用SafeArrayPutElement使用双数据类型值填充SafeArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

*pEventCode is my safearray... dEventCd is the 'double' value...I want to insert the dEventCd values to my *pEventCode safearray one by one when (bPriv) is true... Please help. I get E_INVALIDARG error.







lResult=SafeArrayUnlock(*pEventCode);
HRESULT hr = SafeArrayDestroyData(*pEventCode);

for(INT_PTR count(0); count < nEventCnt; ++count)
{
    mapEventCds.GetNextAssoc(pos, dEventCd, bPriv);

    if (bPriv)
    {
        hr = SafeArrayPutElement(*pEventCode, &iEventCdIdx, &dEventCd);
        iEventCdIdx++;
    }
}

推荐答案

这样的东西与你的代码合并了吗?你必须使用safearray的限制

Something like this merged with your code? You have to work with the limits of the safearray
//Check dimensions of the array:
LONG lLBound, lUBound;
long element; //for array indexing
HRESULT hr;
	
// Get the lower bound of the array
hr = SafeArrayGetLBound(*pEventCode, 1, &lLBound);
if (FAILED(hr))
{
   //Handle Error
}

// Get the upper bound of the array
hr = SafeArrayGetUBound(*pEventCode, 1, &lUBound);
if (FAILED(hr))
{
   //Handle Error
}


// put your array elements into the SAFEARRAY
for( element = lLBound; element <= lUBound; element++ )
{
    hr = SafeArrayPutElement(*pEventCode, &element, &dEventCode);
    if(FAILED(hr))
    {
         // Handle Error
    }	
}


查看http://msdn.microsoft.com/en-us/library/windows /desktop/ms221170(v=vs.85).aspx [ ^ ]似乎没有安全阵列的双重类型 - 我收集的是你的问题。虽然有用户定义的类型,但我还没有看过如何使用它。
Looking at http://msdn.microsoft.com/en-us/library/windows/desktop/ms221170(v=vs.85).aspx[^] there doesn't seem to be a double type for safearray - which I gather is your problem. Though there is a user defined type but I haven't looked at how to use it.


这篇关于如何使用SafeArrayPutElement使用双数据类型值填充SafeArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆