[RESOLVED] E_NOINTERFACE on QueryService(IID_IDISManagerV450)

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Locked
goossenk
Posts: 3
Joined: Tue Nov 02, 2021 2:58 pm

[RESOLVED] E_NOINTERFACE on QueryService(IID_IDISManagerV450)

Post by goossenk »

pPdk->QueryService(P3D::SID_SimObjectManager, P3D::IID_IDISManagerV450, (void**)&disManager) give us an E_NOINTERFACE error and we can't figure out why.
The Prepar3D version we are using is v4 and it is able to connect to DIS. We created a PDK add-on and within this add-on we would like to know either call signs or dis entity id's, but we aren't able to get a hold of P3D::IDISManagerV450. What do we need to do differently to be able to get a reference to P3D::IDISManagerV450?

Code: Select all

#include <Pdk.h>   
#include <InitGuid.h>
#include <ISimObject.h>
#include <ISimObjectDIS.h>

#pragma comment(lib,"user32.lib")

void DisplayQueryDisManagerResult(HRESULT result);

STDMETHODIMP_(void) DLLStart(__in __notnull P3D::IPdk* pPdk)
{
    if (pPdk) {
        CComPtr<P3D::IDISManagerV450> disManager;

        HRESULT result = pPdk->QueryService(P3D::SID_SimObjectManager, P3D::IID_IDISManagerV450, (void**)&disManager);
        DisplayQueryDisManagerResult(result);
    }
    return;
}

STDMETHODIMP_(void) DLLStop()
{

}

void DisplayQueryDisManagerResult(HRESULT result) {

    if (SUCCEEDED(result))
        MessageBox(nullptr, "Loaded \"P3D::IID_IDISManagerV450\" successfully", "message", MB_OK);
    else
    {
        if (result == E_NOINTERFACE)
            MessageBox(nullptr, "Interface not supported error for \"P3D::IID_IDISManagerV450\"", "error", MB_OK);
        else
            MessageBox(nullptr, ("error code: " + std::to_string(result)).c_str(), "error", MB_OK);
    }
}
Mike Schroeter
Lockheed Martin
Posts: 341
Joined: Thu Jan 12, 2012 7:05 pm

Re: E_NOINTERFACE on QueryService(IID_IDISManagerV450)

Post by Mike Schroeter »

I think you may be requesting the wrong service. Try SID_DISManager instead of SID_SimObjectManager.
goossenk
Posts: 3
Joined: Tue Nov 02, 2021 2:58 pm

Re: E_NOINTERFACE on QueryService(IID_IDISManagerV450)

Post by goossenk »

Thank you. That was whole the problem.
Locked