Questions tagged [iunknown]

IUnknown is the fundamental COM (Component Object Model) interface, which the specification mandates must be implemented by all COM objects. All other COM interfaces derive from IUnknown. The IUnknown interface exposes methods for object lifetime management and the ability to access object functionality by retrieving references to other interfaces. (NOTE: This tag is related to Windows programming. Don't use it to mean something is "unknown" to you!)

63 questions
12
votes
3 answers

Delphi: How to implement QueryInterface of IUnknown?

In Delphi, IUnknown is declared as: function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; Note: The output parameter is untyped In my TInterfacedObject descendant i need to handle QueryInterface, so i can return an object that…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
10
votes
2 answers

Assigning interface pointers in a Delphi 6 class declaration?

Despite years of Delphi programming I just ran into a class declaration style I had never seen for a class that supports IUnknown: TBCUnknown = class(TBCBaseObject, IUnKnown) private FRefCount: integer; FOwner : Pointer; protected function…
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
9
votes
4 answers

Does IUnknown::QueryInterface() increment the reference count?

If I have an IUnknown *ptr, do I need to call Release() on every interface I obtain through ptr->QueryInterface(), in addition to calling ptr->Release() when I'm done with ptr? I used to think that the answer is "Yes", but this quote from MSDN…
user541686
  • 205,094
  • 128
  • 528
  • 886
9
votes
2 answers

How to implement custom iterable class in VBA

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…
JayC667
  • 2,418
  • 2
  • 17
  • 31
6
votes
3 answers

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

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…
Carl
  • 1,224
  • 2
  • 19
  • 35
6
votes
0 answers

Why when trying to assign to a variant, an array for some non-IDispatch-exposing object type, is the array pointer assigned instead?

Summary After declaring an array for some object type where the type doesn't use an interface that derives from COM's IDispatch interface (& so isn't properly set-up to enable [OLE] Automation's late-binding technology), trying to assign the array…
6
votes
3 answers

Implementing IUnknown in C#

I've been looking for an example of how to implement IUnknown in C#, but haven't found any decent references or solutions to this. Should it be as simple as... public interface IUnknown { UInt32 AddRef(); UInt32 QueryInterface([In] IntPtr…
Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
5
votes
2 answers

warnings about mystery interfaces in C# projects

Every time I build my C# Solution, I get a handful of warnings about interfaces that I've never seen or written. I tried Googling for some of them, but get no hits. Could these possibly be buried in an assembly I'm referencing? If so, is there…
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
5
votes
2 answers

Add, Remove Folder from IShellLibrary

I am attempting to write two functions that add and remove a folder from a IShellLibrary. I started with this, but the function produces an exception in System._IntfClear: First chance exception at $000007FEFE 168BC4. Exception class $C0000005…
Bill
  • 2,993
  • 5
  • 37
  • 71
3
votes
1 answer

Access violation casting IDispatch in XE2

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…
Mick
  • 846
  • 2
  • 7
  • 18
3
votes
3 answers

Why are COM pointer arguments cast as void instead of IUnknown?

Apologies if this is a stupid question, but I wasn't clear on why COM pointer arguments are typically cast as (void**) instead of (IUnknown**). And then sometimes IUnknown pointers are in fact used, like with IObjectWithSite::SetSite. Can anyone…
user12381459
3
votes
2 answers

Hook IDispatch v-table in C++

I'm trying to modify the behavior of an IDispatch interface already present in the system. To do this my plan was to hook into the objects v-table during runtime and modify the pointers so it points to a custom hook method instead. If I can get this…
monoceres
  • 4,722
  • 4
  • 38
  • 63
3
votes
1 answer

What to do with a COM server method returning an undocumented IUnknown

Some of the methods of a COM interface, which I have imported from a type library (part of a hardware SDK), return or receive a value of type IUnknown. As an example, the SDK documentation specifies the methods as follows: bool…
3
votes
2 answers

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

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…
Mirek
  • 4,013
  • 2
  • 32
  • 47
3
votes
2 answers

C++ Pointer to member function of an UNKNOWN CLASS

DISCLAIMER I DO NOT USE BOOST OR OTHER LIBRARIES Finally I've learned how PointerToMemberFunction works. This is my example code. #include using namespace std; class Foo { public: void foo ( ) { …
Kolyunya
  • 5,973
  • 7
  • 46
  • 81
1
2 3 4 5