idispatch

COM interface created by ATL inherits IDispatch but late binding does not work

无人久伴 提交于 2019-12-22 14:14:38
问题 This my IDL file. IFrame is a dual interface and inherits both IDispatch and IUnknown. [ object, uuid(C5AD0517-37FC-479C-9C7A-A063B17E4A2E), dual, nonextensible, pointer_default(unique) ] interface IFrame : IDispatch{ }; [ uuid(F7D50952-4AF1-491B-B0AA-35083AEFA998), version(1.0), ] library bdsCOMLib { importlib("stdole2.tlb"); [ uuid(9C2E7E2D-A39C-4FE7-BEEB-3BF65F9D4C05) ] coclass Frame { [default] interface IFrame; }; }; And this is the CFrame class declaration which is suppose to implement

COM / OLE / ActiveX / IDispatch confusion

和自甴很熟 提交于 2019-12-20 14:10:31
问题 I can't wrap my head around the differences among these terms. Are COM and ActiveX synonyms? Is ActiveX object just a COM object that exposes IDispatch? Lots of older MSDN pages mention IDispatch without any COM context. Does it have a separate history, and was just introduced under the COM 'umbrella' later in its lifecycle? Where does OLE fit in? Is its (considerable) presence in MFC naming and MSDN in general - all just legacy? Wikipedia gives some insight, but not much. I couldn't find a

Packaging IDispatch Invoke with Parameters in C# (with DISPPARAMS)

ⅰ亾dé卋堺 提交于 2019-12-09 19:00:44
问题 I'm using Invoke for late binding on a legacy COM objects that supports IDispatch. This seems necessary as .NET's Type.GetMethod Type.InvokeMember do not seem to work on these objects. The following code works fine for getting a property from an object, the caller passes in the property name as a string for getting the property value with late binding. The class takes an object in its constructor and sets up this.idisp (and this.lcid) as an interface pointer to the object (Critiques welcome!)

Access violation casting IDispatch in XE2

非 Y 不嫁゛ 提交于 2019-12-06 06:22:27
问题 We're using some old code (ComLib.pas created by Binh Ly) so we can use the enumeration interface on an (OleVariant) object: type TDispNewEnum = dispinterface ['{97079E31-6957-11D2-9154-0000B4552A26}'] // dummy property _NewEnum: IUnknown readonly dispid -4; // DISPID_NEWENUM function _NewEnumFunc: IUnknown; dispid -4; // DISPID_NEWENUM end; procedure TEnumVariant.AttachUnknown (const Unk: IUnknown); var pDisp: IDispatch; _NewEnumPropFailed: boolean; Unknown: IUnknown; begin Detach; Unknown :

Difference between Dual interface and Dispatch only interface for C# COM automation

本小妞迷上赌 提交于 2019-12-06 05:26:06
问题 I am implementing a c# COM client against a C++ COM server. The COM client functions correctly when I mark the COM interface as "Dual" but it throws an InvalidCastException when I remove the "Dual" attribute. Therefore the easy fix for me is to mark it as Dual. But from reading online, it looks like it is not the recommended approach to use for COM servers. Can anyone explain to me the significance (in layman terms) to marking an interface as dual and why it would not be recommended? I only

How does CreateStdDispatch know what method to invoke?

雨燕双飞 提交于 2019-12-06 04:58:25
问题 i'm faced with implementing an IDispatch interface. There are four methods, and fortunately 3 of them are easy: function TIEEventsSink.GetTypeInfoCount(...): HResult; { Result := E_NOTIMPL; } function TIEEventsSink.GetTypeInfo(...): HResult; { Result := E_NOTIMPL; } function TIEEventsSink.GetIDsOfNames(...): HResult; { Result := E_NOTIMPL; } It's the last method, Invoke that is difficult. Here i am faced with having to actually case the DispID , and call my appropriate method; unmarhsalling

Implementing IDispatch in c#

守給你的承諾、 提交于 2019-12-06 00:22:47
问题 I'm writing some test code to emulate unmanaged code calling my c# implementation of a late binding COM object. I have an interface that is declared as an IDispatch type as below. [Guid("2D570F11-4BD8-40e7-BF14-38772063AAF0")] [InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface TestInterface { int Test(); } [ClassInterface(ClassInterfaceType.AutoDual)] public class TestImpl : TestInterface { ... } When I use the code below to call IDispatch's GetIDsOfNames function .. //code

Difference between Dual interface and Dispatch only interface for C# COM automation

假如想象 提交于 2019-12-04 12:58:12
I am implementing a c# COM client against a C++ COM server. The COM client functions correctly when I mark the COM interface as "Dual" but it throws an InvalidCastException when I remove the "Dual" attribute. Therefore the easy fix for me is to mark it as Dual. But from reading online, it looks like it is not the recommended approach to use for COM servers. Can anyone explain to me the significance (in layman terms) to marking an interface as dual and why it would not be recommended? I only need it for testing purposes, and I'm using C# client (don't anticipate that I ever will use VB)

Packaging IDispatch Invoke with Parameters in C# (with DISPPARAMS)

一笑奈何 提交于 2019-12-04 12:38:44
I'm using Invoke for late binding on a legacy COM objects that supports IDispatch. This seems necessary as .NET's Type.GetMethod Type.InvokeMember do not seem to work on these objects. The following code works fine for getting a property from an object, the caller passes in the property name as a string for getting the property value with late binding. The class takes an object in its constructor and sets up this.idisp (and this.lcid) as an interface pointer to the object (Critiques welcome!) public object InvokeGet(string propertyName) { int id = GetDispID(propertyName); IntPtr[] pArgErr =

Access violation casting IDispatch in XE2

白昼怎懂夜的黑 提交于 2019-12-04 12:24:10
We're using some old code (ComLib.pas created by Binh Ly) so we can use the enumeration interface on an (OleVariant) object: type TDispNewEnum = dispinterface ['{97079E31-6957-11D2-9154-0000B4552A26}'] // dummy property _NewEnum: IUnknown readonly dispid -4; // DISPID_NEWENUM function _NewEnumFunc: IUnknown; dispid -4; // DISPID_NEWENUM end; procedure TEnumVariant.AttachUnknown (const Unk: IUnknown); var pDisp: IDispatch; _NewEnumPropFailed: boolean; Unknown: IUnknown; begin Detach; Unknown := Unk; { extract IEnumVariant } if (Unknown <> nil) then begin { try IEnumVariant } if not (Succeeded