iunknown

Exposing events from .NET to COM

 ̄綄美尐妖づ 提交于 2020-01-13 06:54:28
问题 recently I have been encountering problems with exposing events from .NET to COM. I have been successful with this example (conceptually taken from http://blogs.msdn.com/andreww/archive/2008/10/13/exposing-events-from-managed-add-in-objects.aspx): // The delegate type for our custom event. [ComVisible(false)] public delegate void SomeEventHandler(object sender, EventArgs e); // Outgoing (source/event) interface. [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public

Must the IUnknown interface be re-implemented by every new COM class?

≡放荡痞女 提交于 2019-12-23 10:20:46
问题 Sorry if this question seems obvious for everyone, but I am very new to COM. From the tutorial I see here http://www.codeguru.com/cpp/com-tech/activex/tutorials/article.php/c5567, it seems like every COM class created in C++ must implement its own QueryInterface, AddRef and Release. Since these methods should have basically the same implementation for any new class, I don't understand why there isn't some abstract class or whatever that implements it for the developer. I don't understand why

C++ Pointer to member function of an UNKNOWN CLASS

落爺英雄遲暮 提交于 2019-12-07 22:58:38
问题 DISCLAIMER I DO NOT USE BOOST OR OTHER LIBRARIES Finally I've learned how PointerToMemberFunction works. This is my example code. #include <iostream> using namespace std; class Foo { public: void foo ( ) { cout << "I'm a foo method\n"; }; }; class Bar { public: void bar ( Foo* fooPtr , void(Foo::*fooFnPtr)() ) { (fooPtr->*fooFnPtr)(); }; }; int main() { Foo* foo = new Foo(); Bar* bar = new Bar(); bar->bar ( foo , &Foo::foo ); return 0; } Now, what the problem is. Bar::bar must be modified

C++ Pointer to member function of an UNKNOWN CLASS

大憨熊 提交于 2019-12-06 07:30:13
DISCLAIMER I DO NOT USE BOOST OR OTHER LIBRARIES Finally I've learned how PointerToMemberFunction works. This is my example code . #include <iostream> using namespace std; class Foo { public: void foo ( ) { cout << "I'm a foo method\n"; }; }; class Bar { public: void bar ( Foo* fooPtr , void(Foo::*fooFnPtr)() ) { (fooPtr->*fooFnPtr)(); }; }; int main() { Foo* foo = new Foo(); Bar* bar = new Bar(); bar->bar ( foo , &Foo::foo ); return 0; } Now, what the problem is. Bar::bar must be modified somehow, because in real project it won't know, what class fooFnPtr is a pointer to . In other words Bar:

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 :

Exposing events from .NET to COM

霸气de小男生 提交于 2019-12-04 19:47:07
recently I have been encountering problems with exposing events from .NET to COM. I have been successful with this example (conceptually taken from http://blogs.msdn.com/andreww/archive/2008/10/13/exposing-events-from-managed-add-in-objects.aspx ): // The delegate type for our custom event. [ComVisible(false)] public delegate void SomeEventHandler(object sender, EventArgs e); // Outgoing (source/event) interface. [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IAddInEvents { [DispId(1)] void SomeEvent(object sender, EventArgs e); } [ComVisible(true)]

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

Convert/cast SAFEARRAY of IUnknowns to an iterable array of interface pointers

拈花ヽ惹草 提交于 2019-12-02 04:01:52
问题 I have the following interface in C# with a class with a same name (without I) implementing it. [ComVisible(true)] [Guid("B2B134CC-70A6-43CD-9E1E-B3A3D9992C3E")] public interface IOrder { long GetQuantity(); long GetOrderType(); long GetPositionType(); } The implementation of the public class Order : IOrder is just three private fields and a constructor with required 3 parameters. Somewhere else, I have the following method with a result with which I want to work inside a C++ unmanaged code,

How to implement custom iterable class in VBA

随声附和 提交于 2019-11-27 03:27:31
问题 I want to add a feature to my classes so I can use them in for-each loops. I wrote hashmaps, arraylists, queues, sets and so on that I want to iterate over. Now I'm looking for a way to implement the IUnknown class to build custom iterators. I already know how to use private objPeople as Collection Public Property Get NewEnum() As IUnknown Attribute NewEnum.VB_UserMemId = -4 Attribute NewEnum.VB_MemberFlags = "40" Set NewEnum = objPeople.[_NewEnum] End Property but all those examples out