September 20, 200619 yr I am trying to get some data out of a SafeArray using Visual C++ 6.0 and am having some problems.I found an article on microsoft's website (http://support.microsoft.com/kb/167668/EN-US/) to convert a VARIANT type to a SafeArray and then get the upper and lower bounds to iterate through the array getting each element, which is what I want to do. However it throws and unhandled exception (OLEAUT32.DLL): Access Violation. When debugging through my code this exception happens at the line:hr = SafeArrayGetLBound(psa, 1, &lLBound); Here is a larger snippet of surrounding code:SAFEARRAY FAR* psa = NULL;BSTR HUGEP *pbstr;long lLBound, lUBound, cElements;psa = V_ARRAY(&(IQuery->Response));hr = SafeArrayGetLBound(psa, 1, &lLBound);hr = SafeArrayGetUBound(psa, 1, &lUBound);hr = SafeArrayAccessData(psa, (void HUGEP* FAR*)&pbstr);cElements = lUBound - lLBound + 1;for (long i = 0; i < cElements-1; i++) { ... }Why is this throwing an exception?Is there a better way to get the data out of the safearray than this?Thanks
September 20, 200619 yr Any specific reasons for using SafeArray, other than "just because I can"?However it throws and unhandled exception (OLEAUT32.DLL): Access Violation."Safe"...
September 21, 200619 yr Author That is how the data is stored in the IQuery->Response object, as a SafeArray. If there is a better way to get the data out then I'm open to it. Using C# I know how to get the data out, but that is not an option here. I have to use C++ in Visual Studio 6.0
Create an account or sign in to comment