Usage of IMMNotificationClient to register endpoint notifications lazarus / 34-Windows ---------------------------------------------------------------------- Nevada Smith · 2022-05-19 14:34 I am trying to use Windows Core API to register for notifications on audio device changes. I am able to create a IMMDeviceEnumerator. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DeviceEnum := CreateComObject(CLASS_IMMDeviceEnumerator) as IMMDeviceEnumerator; As the next step, I need to use RegisterEndpointNotificationCallback to register for notifications. I am assuming I have to do something like, but I might be wrong. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i OleCheck(De viceEnum.RegisterEndpointNotificationCallback(IMMNotificationClient(@N otificationClient))); However, I do not know how to instantiate IMMNotificationClient. 1. If I have to use CreateComObject , I do not know the CLSID. I have gone through header files in Mingw, but I could not find the CLSID. 2. In certain C projects, they mock a C++ (COM) object starting with a struct and then by adding appropriate methods. Please advise... ---------------------------------------------------------------------- Nevada Smith · 2022-05-19 17:52 This was sort of a stupid question. It was as simple as : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TDeviceListener = class(TObject, IMMNotificationClient) You have to implement the virtual methods from IUnknown from which IMMNotificationClient is derived. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TDeviceListener.QueryInterface(constref  iid: TGuid; out obj): HRESULT;  stdcall;begin     // Returning S_OK blinging is not entirely correct, but sort of does the job for proof-of-concept     Result := S_OK;end; function TDeviceListener._AddRef(): HRESULT; stdcall;begin  Inc(FRefCount);  Result:=FRefCount;end; function TDeviceListener._Release(): HRESULT; stdcall;begin  Dec(FRefCount);  Result:=FRefCount;end;                                                                         And then use it  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i OleCheck(DeviceEnum.RegisterEndpointNotificationCallback(Self)); ---------------------------------------------------------------------- trev · 2022-05-20 03:48 Thanks for bothering return to let us know how you solved the issue. It may well help another user in the future. ---------------------------------------------------------------------- PascalDragon · 2022-05-20 14:09 Quote from: Nevada Smith on May 19, 2022, 07:52:33 pmThis was sort of a stupid question. It was as simple as : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TDeviceListener = class(TObject, IMMNotificationClient) Best inherit from TInterfacedObject instead of TObject as that already provides suitable implementations for QueryInterface, _AddRef and _Release.