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
1
vote
2 answers

What is the correct way to cast when using ATL and IUnknownPtr?

During the modification of an existing ATL COM object I came across an article from the "The Old New Thing" blog called "The ways people mess up IUnknown::QueryInterface" and there was a discussion in the comments section that started when one of…
Peter Nimmo
  • 1,045
  • 2
  • 12
  • 25
1
vote
2 answers

How to pass IUnknown argument to a COM interface using C#?

I have a COM interface defined like this interface Client : IUnknown { [id(1)] HRESULT GetSomething ( enum SomeID someID, [out] IUnknown **pUnknown ); }; How can I pass IUnknown object using C#?
1
vote
4 answers

Problem with D3D & COM

all the D3D interfaces are derived from COM's IUnknown interface, so I though I'd take an easy route for releasing D3D objects and use something like this: __inline BOOL SafeRelease(IUnknown*& pUnknown) { if(pUnknown != NULL &&…
Necrolis
  • 25,836
  • 3
  • 63
  • 101
1
vote
1 answer

How to get IUnknown from WDM driver CreateInstance

In documentation (C++ example) LUnknown* pIUnknown = CreateInstance(slot); I try this >> import ctypes >> print type(ctypes.cdll.lcomp.CreateInstance(0)) How to get IUNKNOWN and QueryInterface?
estin
  • 3,051
  • 1
  • 24
  • 31
1
vote
3 answers

Cast DirectX interfaces to IUnknown pointers

Having quite a few interfaces in my code, I wanted to encapsulate repeating Release code in another method and not in a macro because this is C++ and I hate using macros. My initial attempt was to write a method such as void SafeRelease(IUnknown…
Christian Ivicevic
  • 10,071
  • 7
  • 39
  • 74
1
vote
3 answers

Is it worth checking for null pointer in QueryInterface() implementation?

IUnknown::QueryInterface() is passed a void** parameter denoting an address where to put the retrieved interface. STDMETHOD QueryInterface(/* [in] */ REFIID riid, /* [iid_is][out] */ void** ppvObject) Should the implementation of QueryInterface()…
sharptooth
  • 167,383
  • 100
  • 513
  • 979
1
vote
2 answers

Pass .NET Bitmap object to COM (DirectShow filter)

I'm trying to create a source filter that makes a live video stream based on a sequence of pictures. To do this, I make an interface of IUnknown: [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown),…
no.Oby
  • 107
  • 8
0
votes
1 answer

Implications for COM Interfaces that don't inherit from IUnknown

I am trying to implement some COM interfaces that can be used while exporting Word documents as PDF. Some of these interfaces don't inherit from IUnknown, for instance: #undef INTERFACE #define INTERFACE …
VersBersch
  • 193
  • 1
  • 8
0
votes
1 answer

Does dynamic work with IUnknown and Typelib

Currently I'm experimenting with C#4's dynamic programming and I did not completely understand under which circumstances the keyword dynamic works. It is clear to me that it works with IDispatch, as it allows to inform the caller with type…
Nico
  • 1,554
  • 1
  • 23
  • 35
0
votes
1 answer

My every project files and class suddenly turned into an strange format

Everything was good. Today, I opened Android Studio, and every kotlin class code and even layout and value files turned into another format like XML. I don't know what kind of strange reason it is. I have been trying to fix this for 2 days now. even…
0
votes
0 answers

SystemError: <built-in function compile> returned NULL without setting an error

When i was using pycharm to process yolov5 codes,i got this wrong,here was my details about my question. Traceback (most recent call last): File "", line 1, in SystemError: returned NULL without setting…
J Alux
  • 1
0
votes
1 answer

What is the correct way to handle IUnknown Reference count with multiple interfaces in type library?

I have C# Type Library that has multiple interfaces defined. This outputs to a single .tlb file – called BACnetLib.tlb First is an interface for HTTP communications. namespace WebServiceLib { [ComVisible(true)] …
ChrisJ
  • 181
  • 14
0
votes
0 answers

Hide specific methods of a typed class in a smart pointer

I use the following code template std::shared_ptr comToShared(T* comObject) { comObject->AddRef(); return std::shared_ptr(comObject, [=](auto) { comObject->Release(); }); } to convert a COM object into a…
Duncan
  • 443
  • 1
  • 5
  • 12
0
votes
1 answer

Why IHTMLDocument2 is not equal to IHTMLDocument2.body.document?

Why is the following doc2 different from doc22? IHTMLDocument2 doc2 = (pDisp as IWebBrowser2).Document as IHTMLDocument2; IHTMLDocument2 doc22 = doc2.body.document as IHTMLDocument2; bool isequal = Marshal.GetIUnknownForObject(doc2) ==…
Calvin Kwok
  • 161
  • 1
  • 9
0
votes
1 answer

why my IUnknown release function block my child thread?

In my C application, I have a child thread that retrieve a IUnknown interface at beginning of his life : static struct IUnknown* punk = NULL; void DispatcherStart(){ CoInitialize(NULL); …
Xemuth
  • 415
  • 3
  • 12