IUnknown
Encyclopedia
In programming, the IUnknown interface
Interface (computer science)
In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software...

 is the fundamental interface in the Component Object Model
Component Object Model
Component Object Model is a binary-interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess communication and dynamic object creation in a large range of programming languages...

 (COM). The published COM specification mandates that COM objects must minimally implement this interface. Furthermore, every other COM interface must be derived from IUnknown.

Methods

The IUnknown interface exposes three methods
Method (computer science)
In object-oriented programming, a method is a subroutine associated with a class. Methods define the behavior to be exhibited by instances of the associated class at program run time...

 (sometimes called functions): QueryInterface, AddRef, and Release:
  • QueryInterface is used to obtain a pointer to another interface, given a GUID
    Globally Unique Identifier
    A globally unique identifier is a unique reference number used as an identifier in computer software. The term GUID also is used for Microsoft's implementation of the Universally unique identifier standard....

     that uniquely identifies that interface (commonly known as an interface ID, or IID). If the COM object does not implement that interface, an E_NOINTERFACE error is returned instead.
  • AddRef is used by clients to indicate that a COM object is being referenced. This is necessary to ensure that a COM object is not disposed prematurely.
  • Release is used by clients to indicate that they have finished using the COM object. An unreferenced COM object may be safely disposed.


interface IUnknown
{
virtual HRESULT QueryInterface(REFIID riid, void **ppvObject) = 0;
virtual ULONG AddRef(void) = 0;
virtual ULONG Release(void) = 0;
};

The IUnknown interface ID is defined as a GUID
Globally Unique Identifier
A globally unique identifier is a unique reference number used as an identifier in computer software. The term GUID also is used for Microsoft's implementation of the Universally unique identifier standard....

 with the value of {00000000-0000-0000-C000-000000000046}.

Miscellaneous

  • Components designed under the ActiveX
    ActiveX
    ActiveX is a framework for defining reusable software components in a programming language-independent way. Software applications can then be composed from one or more of these components in order to provide their functionality....

     standard must, at minimal, implement the IUnknown interface.
  • IUnknown serves as the base for Mac OS X
    Mac OS X
    Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

    's Core Foundation
    Core Foundation
    Core Foundation is a C application programming interface in Mac OS X & iOS, and is a mix of low-level routines and wrapper functions...

    CFPlugIn framework.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK