Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

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.

VARIANT bzw. _variant_t

Empfohlene Antworten

Veröffentlicht

Hallo :)

habe folgendes Problem:

eine Funktion liefert mit ein _variant_t.

in dem in einem "SAFAARRAY of R8" meine double-Werte stecken (ich kann die im debugger sehen)

nur ich krieg die nicht raus.

also

_variant_t var = funktion();

double firstDouble = var???

sitze schon seit 2 Stunden und komme nicht wieter.

währe seht dankbar für die Hilfe!!

gruss

So wie ich das lese solltest du eigendlich einfach mit "double value = (double)var;" darauf zugreifen können, da dieser entsprechende operatoren zur Verfügung stellt.

Welchen Fehler bringt der Compiler, wenn du dies versuchst ?

  • Autor

Unhandled exception at 0x7c81eb33 in acad.exe: Microsoft C++ exception: _com_error at memory location 0x0b77f910..

das dürfte auch nicht funktionieren, weil in der var ja mehrere werte drin sind.

trotzdem danke

gruss

Der _variant_t hat eine VARIANT enthalten, auf welche (nach msdn) über die Operatoren zB operator double() zugegriffen werden kann. Allerdings gilt dies für _variant_t, dies ist die kapselnde Klasse., nicht für VARIANT.

Kannst du mir eine Beispielfunktion nennen, welche ein _variant_t zurückgibt ? (System oä).

Zusatz : Die VARIANT scheint nur eine Variable (Daten) zu enhalten, welche in einem union als unterschiedliche Werte dargestellt werden kann.(zugriff variant.dblVal für Doublewerte, variant ist ein VARIANT).

  • Autor

danke, jetzt gehts:

COleSafeArray dias(mein _variant_t);

long bound;

dias.GetUBound(1, &bound);

double *myDias = new double[(int)bound];

for (long i = 0; i <= bound; ++i)

dias.GetElement(&(long)i, &myDias);

gruss

Sorry, lerne das grad. ;-)

Wie gesagt, eine VARIANT ist ein union. Dies kann auch ein SAFEARRAY aein, VARIANT.parray.

Der Zugriff (per API) sollte mit SafeArrayAccessData stattfinden.

(Beispiel aus MSDN) :

psa -> SAFEARRAY ( = variant.parray)

long i, j, min;

BSTR bstrTemp;

BSTR HUGEP *pbstr;

HRESULT hr;

// Get a pointer to the elements of the array.

hr = SafeArrayAccessData(psa, (void HUGEP**)&pbstr);

if (FAILED(hr))

goto error;

// Selection sort.

for (i = 0; i < psa->rgsabound.cElements-1; i++)

{

min = i;

for (j = i+1; j < psa->rgsabound.cElements; j++)

{

if (wcscmp(pbstr[j], pbstr[min]) < 0)

min = j;

}

// Swap array[min] and array.

bstrTemp = pbstr[min];

pbstr[min] = pbstr;

pbstr = bstrTemp;

}

SafeArrayUnaccessData(psa);

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.