下面是我的程序:
STDMETHODIMP CComprisePaper::CreateExampaper(BSTR subject,SAFEARRAY **knowpoint,BSTR difficulty,long number,long score)
然后在这个函数中调用一个函数,我写成了下面的
void CComprisePaper::CreateQuestionID(BSTR subject,SAFEARRAY *knowpoint,long score)
然后要在这个函数中使用传入的安全数组中的BSTR值查询数据库,现在我不会使用这个SAFEARRAY啦,而且我不知道这个函数写的是不是对。
那位帮我写一点,我看看吧。
问题解决,分数好说。
参考Platform SDK Document----Component Service----COM----Automation----Conversion and Manipulation Functions。
http://www.codeguru.com/activex/csafe.shtml
A Simple SafeArray wrapper
SAFEARRAY* psa;
SAFEARRAYBOUND bounds = {8, 0};
psa = SafeArrayCreate(VT_BSTR, 1, &bounds);
BSTR* bstrArray;
SafeArrayAccessData(psa, reinterpret_cast<void**>(&bstrArray));
int i = 0;
for(it = 0; it != 8; it++, i++)
{
bstrArray[i] = SysAllocString(T2OLE("VALUES"));
}
SafeArrayUnaccessData(psa);