craziscoth Posted September 20, 2006 Share Posted September 20, 2006 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 Link to comment Share on other sites More sharing options...
LLXX Posted September 20, 2006 Share Posted September 20, 2006 Any specific reasons for using SafeArray, other than "just because I can"?However it throws and unhandled exception (OLEAUT32.DLL): Access Violation."Safe"... Link to comment Share on other sites More sharing options...
craziscoth Posted September 21, 2006 Author Share Posted September 21, 2006 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now