我正在尝试使用提供给我的以下示例代码
// select the Access levels from access level list
BSTR myBstr = SysAllocString(L"Hello World");
COleSafeArray saAccessLevels;
VARIANT vAccls;
saAccessLevels.CreateOneDim(VT_BSTR, 1);
saAccessLevels.PutElement(0, myBstr); // <-- Error after this line
vAccls = saAccessLevels.Detach();
Visual C ++调试器在上面的注释中注明的行中断,我得到以下错误:
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\olemisc.cpp(423) : AppMsg - Warning: constructing COleException, scode = E_INVALIDARG ($80070057).
First-chance exception at 0x75371D4D in MyApplication.exe: Microsoft C++ exception: COleException at memory location 0x0057FC58.
Unhandled exception at 0x75371D4D in MyApplication.exe: Microsoft C++ exception: COleException at memory location 0x0057FC58.
我不熟悉C ++编程。我究竟做错了什么?