2
votes

and thank you in advance for any advice / insight / assistance that can be provided.

The Background:

We have a soft phone application that is written in Delphi (XE3) for Windows. The ability to answer an incoming call by activating the answer button an a Plantronics Wireless Headset was recently requested. The MSI files were downloaded and executed, and the Plantronics SDK was converted / altered into a Delphi Library File.

I then started to follow the "First Steps" section of the Plantronics Website. I knew that the "First Steps" code would have to be tweaked to fit the Delphi system.

The Problem:

In adjusting the code to work within Delphi, a few translation problems were encountered and resolved. One such error is proving to be stubborn - When an instance of one specific class is created, the error "Class not registered" is thrown.

"First Steps" code for reference -

//  Connect to the Plantronics COM API:
myAppName = "SDK .NET COM sample";
sessionManager = new COMSessionManager();
sessionManager.Register(myAppName, out session);

// Hook to SessionManager events:
sessionManagerEvents = sessionManager as ICOMSessionManagerEvents_Event;
if (sessionManagerEvents != null)
{
    sessionManagerEvents.onCallStateChanged += SessionManagerEvents_onCallStateChanged;
    sessionManagerEvents.onDeviceStateChanged += SessionManagerEvents_onDeviceStateChanged;
}

Delphi Code:

//Connect to the Plantronics COM API:
plugin_name: "Plugin Name";
the_session: CoCOMSession.Create;
session_manager = new COMSessionManager.Create;
session_manager.Register(plugin_name, the_session);

//Hook to Session Manager Events
state_device_event_args := CoCOMStateDeviceEventArgs.Create;
call_event_args := CoCOMCallEventArgs.Create;

The final line of Delphi Code is the issue. The other three "Create" calls go off without a hitch. The line "call_event_args := CoCOMCallEventArgs.Create;" throws the error "Class not registered", even through it is declared and implemented in the library file along with the other three.

Excerpts from the library file:

Class Declarations:

IID_ICOMStateDeviceEventArgs: TGUID = '{91542BEE-4931-4620-9E96-23AE4001E93F}';
CLASS_COMStateDeviceEventArgs: TGUID = '{335D08FD-8BB5-4EF5-964B-E8A8C010530F}';

IID_ICOMCallEventArgs: TGUID = '{0280956C-C644-4CD8-B124-C8A99E5D505E}';
CLASS_COMCallEventArgs: TGUID = '{705129C3-2265-4F10-9768-0FF8A20234C0}';

Class creation functions:

//Works
class function CoCOMStateDeviceEventArgs.Create: ICOMStateDeviceEventArgs;
begin
    Result := CreateComObject(CLASS_COMStateDeviceEventArgs) as ICOMStateDeviceEventArgs;
end;

// Doesn't Work
class function CoCOMCallEventArgs.Create: ICOMCallEventArgs;
begin
  Result := CreateComObject(CLASS_COMCallEventArgs) as ICOMCallEventArgs;
end;

Every tutorial / forum answer about resolving the "Class Not Registered" error that I have found has not resolved the issue.

Does anyone have any advice or insight as to what I have been doing wrong?

Thank you.

1
Why not just have Delphi create component wrappers when you import the type library, and use the components? You can then just create the events using the Object Inspector like any other event handler. - Ken White

1 Answers

0
votes

The issue has been (potentially) resolved by the following -

I had mistakenly thought from the tutorial / first steps section that a "COMCallEventArgs" object needed to be created before it could be used.

Upon further review, the COMCallEventArgs object gets created when necessary at a later point.

More testing needs to be done, but I believe this issue is resolved.