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.

Empfohlene Antworten

Veröffentlicht

Hi,

wie kann ich überprüfen ob ein angeforderter Pointer auf eine COM Schnittstelle

überhaupt gültig ist?

Weil im nachfolgendem Code bekomme ich immer ein Access Violation:


hFlash = GetDlgItem(hDlg,IDC_FLASH);
if (hFlash == NULL)
Fehler("hFlash == 0",0);
AtlAxGetHost(hFlash,(IUnknown**)&pIFlashAmbient);
if (pIFlashAmbient == NULL)
Fehler("pIFlashAmbient == 0",0);
pIFlashAmbient->put_BackColor(COLOR_WINDOW); //Access Violation
[/PHP]

Ich meine da mal was in der Art von IsValid() oder so gelesen zu haben, konnte

es aber nicht mehr finden.

Gruß

Guybrush

  • Autor

Ok, habs jetzt so gelöst wie du gesagt hast.

Die letzte Zeile bewirkt zwar irgendwie nichts, aber wenigstens kommt

keine Access Violation mehr.


hFlash = GetDlgItem(hDlg,IDC_FLASH);
if (hFlash == NULL)
Fehler("hFlash == 0",0);
AtlAxGetHost(hFlash,&pIUnknown);
pIUnknown->QueryInterface(IID_IAxWinAmbientDispatch,
(void**)&pIFlashAmbient);
if (pIFlashAmbient == NULL)
Fehler("pIFlashAmbient == 0",0);
pIFlashAmbient->put_BackColor(COLOR_GRAYTEXT);
[/PHP]

Um nochmal zum Thema zurückzukommen, bewirkt es eigentlich etwas

sinnvolles wenn ich den Interfacepointer auf NULL überprüfe?

Danke!

Gruß

Guybrush

Originally posted by Guybrush Threepwood

Um nochmal zum Thema zurückzukommen, bewirkt es eigentlich etwas

sinnvolles wenn ich den Interfacepointer auf NULL überprüfe?

Sicher. Das Problem hier war aber kein Nullzeiger, sondern eine vtable, der so gar nicht da war. An der Stelle der vtable von IAxWinAmbientDispatch, an der put_BackColor steht, ist die vtable von IUnknown (die ja nur drei Einträge hat) schon lange vorbei. Aber das, was da steht, wird als Funktionszeiger interpretiert und aufgerufen. Da ist eine Schutzverletzung nicht weiter verwunderlich. ;)

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.