@Test public void Advise() { // query for ConnectionPointContainer Unknown unk = new Unknown(this.ppWordApp.getValue()); PointerByReference ppCpc = new PointerByReference(); IID cpcIID = new IID("{B196B284-BAB4-101A-B69C-00AA00341D07}"); HRESULT hr = unk.QueryInterface(new REFIID.ByValue(cpcIID), ppCpc); COMUtils.checkRC(hr); ConnectionPointContainer cpc = new ConnectionPointContainer(ppCpc.getValue()); // find connection point for Application_Events4 IID appEvnts4 = new IID("{00020A01-0000-0000-C000-000000000046}"); REFIID riid = new REFIID(appEvnts4.getPointer()); PointerByReference ppCp = new PointerByReference(); hr = cpc.FindConnectionPoint(riid, ppCp); COMUtils.checkRC(hr); ConnectionPoint cp = new ConnectionPoint(ppCp.getValue()); IID cp_iid = new IID(); hr = cp.GetConnectionInterface(cp_iid); COMUtils.checkRC(hr); Application_Events4 listener = new Application_Events4(); DWORDByReference pdwCookie = new DWORDByReference(); hr = cp.Advise(listener, pdwCookie); COMUtils.checkRC(hr); Assert.assertTrue(listener.QueryInterface_called); }
@Test public void queryInterface_ConnectionPointContainer() { Unknown unk = new Unknown(this.ppWordApp.getValue()); PointerByReference ppCpc = new PointerByReference(); IID cpcIID = new IID("{B196B284-BAB4-101A-B69C-00AA00341D07}"); HRESULT hr = unk.QueryInterface(new REFIID.ByValue(cpcIID), ppCpc); COMUtils.checkRC(hr); ConnectionPointContainer cpc = new ConnectionPointContainer(ppCpc.getValue()); }
@Test public void FindConnectionPoint() { // query for ConnectionPointContainer Unknown unk = new Unknown(this.ppWordApp.getValue()); PointerByReference ppCpc = new PointerByReference(); IID cpcIID = new IID("{B196B284-BAB4-101A-B69C-00AA00341D07}"); HRESULT hr = unk.QueryInterface(new REFIID.ByValue(cpcIID), ppCpc); COMUtils.checkRC(hr); ConnectionPointContainer cpc = new ConnectionPointContainer(ppCpc.getValue()); // find connection point for Application_Events4 IID appEvnts4 = new IID("{00020A01-0000-0000-C000-000000000046}"); REFIID riid = new REFIID(appEvnts4.getPointer()); PointerByReference ppCp = new PointerByReference(); hr = cpc.FindConnectionPoint(riid, ppCp); COMUtils.checkRC(hr); ConnectionPoint cp = new ConnectionPoint(ppCp.getValue()); }