Question TAPI: Register TapiEventInterface

Hi everybody,

OE12.8, Win10 x64

Still struggeling with TAPI. Now I have a C++ code that's definitely working, so I try to translate it to ABL. But I'm stuck with the following code-snippet.

Code:
/////////////////////////////////////////////////////////////////////////////
// RegisterTapiEventInterface(CTAPIEventNotification *pTAPIEventNotification)
/////////////////////////////////////////////////////////////////////////////

HRESULT RegisterTapiEventInterface(CTAPIEventNotification *pTAPIEventNotification)
{
    HRESULT hr = S_OK;
    IConnectionPointContainer *pCPC = NULL;
    IConnectionPoint *pCP = NULL;

    // Assuming gpTapi is a valid ITTAPI* instance
    hr = gpTapi->QueryInterface(IID_IConnectionPointContainer, (void **)&pCPC);
    if (SUCCEEDED(hr)) {
        hr = pCPC->FindConnectionPoint(IID_ITTAPIEventNotification, &pCP);
        pCPC->Release();
    }
    if (SUCCEEDED(hr)) {
        // Advise the connection point, receiving a cookie if necessary
        hr = pCP->Advise(pTAPIEventNotification, &g_dwCookie);
        pCP->Release();
    }
    return hr;
}

Could somebody help please ?

TIA, Wolf
 
AI says to write an .NET Wrapper and then consume the .NET Wrapper and subscribe to the events.
I already played around with AI for 2 days, you get a lot of "possible solutions" but none of them works, sometimes the answers are definitely wrong. AI sometimes proposes to use "ENABLE-EVENTS", in other answers it says something like its not possible at all to use TAPI3 directly from Openedge. So I gave up with AI and want to use the C++ code, because I definitely know that this code works.

Have already read about this .NET Wrapper, but this I understand even less than transforming a C++ code to ABL.
 
Agree about AI giving a lot of possible solutions as when I tried doing conversations from C++ to C#/VB.NET the solutions were certainly not the same. Progress say this regarding TAPI:


I can translate some of the code snippet and if any help this is what I have come up with but it is purely guess work - especially the GUID values - as there are workings I have just never accounted before:

Code:
FUNCTION RegisterTapiEventInterface RETURNS INTEGER (pTAPIEventNotification AS ITTAPIEventNotification):
   DEFINE VARIABLE hr AS INTEGER NO-UNDO.
   DEFINE VARIABLE pCPC AS System.Runtime.InteropServices.ComTypes.IConnectionPointContainer NO-UNDO.
   DEFINE VARIABLE pCP AS System.Runtime.InteropServices.ComTypes.IConnectionPoint NO-UNDO.

   // Assuming gpTapi is a valid ITTAPI* instance
   hr = gpTapi:QueryInterface(GetType(System.Runtime.InteropServices.ComTypes.IConnectionPointContainer):GUID, pCPC).
   IF hr >= 0 THEN DO:  // SUCCEEDED(hr)
      hr = pCPC:FindConnectionPoint(GetType(ITTAPIEventNotification):GUID, pCP).
      // One translation suggested pCP = pCPC:FindConnectionPoint(NEW System.Guid:NewGuid(IID_ITTAPIEventNotification)).
      System.Runtime.InteropServices.Marshal:ReleaseComObject(pCPC).
   END.
   IF hr >= 0 THEN DO:  // SUCCEEDED(hr)
      // Advise the connection point, receiving a cookie if necessary
      hr = pCP:Advise(pTAPIEventNotification, g_dwCookie).
      System.Runtime.InteropServices.Marshal:ReleaseComObject(pCPC).
   END.

   RETURN hr.
END FUNCTION.

Regarding a .NET Wrapper. In C++ create a .NET DLL, add it to assemblies.xml and reference the RegisterTapiEventInterface function as you would any other .NET component method in Progress.

Another option is to create a standard external DLL in C++ and call it in Progress using something similar to:

Code:
PROCEDURE RegisterTapiEventInterface EXTERNAL "C:\Tapi.dll" CDECL:
   DEFINE INPUT PARAMETER pTAPIEventNotification AS ITTAPIEventNotification NO-UNDO.
   DEFINE OUTPUT PARAMETER pHr AS INTEGER NO-UNDO.
 END.

DEFINE VARIABLE hr AS INTEGER NO-UNDO.

RUN RegisterTapiEventInterface (INPUT TAPIEventNotification,
                                OUTPUT hr).

MESSAGE hr VIEW-AS ALERT-BOX INFO BUTTONS OK.
 
Back
Top