Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[c++] SafeArray Help

Featured Replies

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


Any specific reasons for using SafeArray, other than "just because I can"?

However it throws and unhandled exception (OLEAUT32.DLL): Access Violation.
"Safe"... :lol:
  • 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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.