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
2
votes
1 answer

How to pass a COM Object/Interface to a VBA method without changing its ObjPtr (i.e. no IUnknown::QueryInterface)?

I'm wondering if there's any way to declare the parameter to a method in such a way that it always preserves the exact ObjPtr/Interface supplied. I've tried every combo of As Object/IUnknown, ByRef/ByVal I can think of: Option Explicit Sub t() …
Greedo
  • 4,967
  • 2
  • 30
  • 78
2
votes
1 answer

Overload COM class methods with methods from a standard module using VTable hacking

Quick question - I've just been testing overwriting methods of a class by changing entries in its VTable using low level copy memory api. Background I've had some success, and can swap 2 entries in the VTable of a class if they have the same…
Greedo
  • 4,967
  • 2
  • 30
  • 78
2
votes
1 answer

"Unable to cast" exceptions originating in `System.Transactions.JitSafeGetContextTransaction`?

Just recently my app has been inconsistently throwing a variety of exceptions like these: Unable to cast object of type 'System.Threading.Thread' to type 'System.Transactions.SafeIUnknown'. Unable to cast object of type…
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
2
votes
2 answers

Exposing events from .NET to COM

recently I have been encountering problems with exposing events from .NET to COM. I have been successful with this example (conceptually taken from…
petr k.
  • 8,040
  • 7
  • 41
  • 52
2
votes
1 answer

ConnectEx returns false and WSAGetLastError returns 0

this snippet is part of a function that should return true when a socket is connected (or connecting) or false if anything fails. if(bind(socket_, reinterpret_cast(&any), sizeof any) < 0) { DWORD err = GetLastError(); …
user666412
  • 528
  • 8
  • 18
2
votes
3 answers

Should I always call Release on COM pointers when my program terminates?

I know that modern Windows versions reclaim memory that was previously acquired with malloc, new and the like, after program termination, but what about COM objects? Should I call obj->Release() on them on program's exit, or will the system do this…
Abel
  • 56,041
  • 24
  • 146
  • 247
2
votes
2 answers

Get IUnkown using window handle

I know this may be a long shot so forgive me as I don't really know that much about COM. Basically what I am trying to do is get the pointer to the IUnknown interface for a running application, the problem is the only thing I know about the app is…
Nathan W
  • 54,475
  • 27
  • 99
  • 146
2
votes
1 answer

VB6 to C#: IUnknown

I have a property in VB6 that I am trying to convert to C#. It is as follows: Public Property Get NewEnum() As IUnknown 'this property allows you to enumerate 'this collection with the For...Each syntax Set NewEnum =…
Logan B. Lehman
  • 4,867
  • 7
  • 32
  • 45
2
votes
2 answers

Implementing IUnknown, unresolved external symbol

I am trying to create a class that implements the IUnknown interface. I have the following code in the header file: #pragma once #include "stdafx.h" #include "Unknwn.h" class Vmr9Presenter : IVMRImagePresenter9,…
Alex
  • 322
  • 2
  • 13
1
vote
1 answer

Using IUnknown derived ATL COM object in .NET

My IDL: [ object, uuid(52D64BCC-03F1-442B-BED1-70992111E2B1), helpstring("ISimpleObject Interface"), pointer_default(unique) ] interface ISimpleObject : IUnknown{ [helpstring("method Hoop"), local] HRESULT Hoop(void); }; [ …
vpp
  • 319
  • 1
  • 3
  • 10
1
vote
3 answers

Representing IUnknown In Managed C++

I building Wrapper in C++/CLI for C Static library to be used in .NET application through C# I have function like this in C long My_COM_Interface( PVOID hDevice,IUnknown **pUnknown); How to declare IUnknown ** in C++/CLI for first argument I…
Vikram Ranabhatt
  • 7,268
  • 15
  • 70
  • 133
1
vote
1 answer

How to manage .Net's RCW COM object creation paramets (namely requested interface)?

I'm using an external native COM component in my C# .NET application. This COM DLL doesn't have a type library, so I had to write the interop code myself, and having include/idl files I did it like TlbImp does. But the worst thing is that the object…
mistika
  • 2,363
  • 2
  • 21
  • 25
1
vote
1 answer

Pointer to the IUnknown of the IShellItemArray for the IFileOperation::DeleteItems method

I am trying to implement the IFileOperation interface and need help with understanding the punkItems parameter of the IFileOperation::DeleteItems method. On the documentation page the punkItems parameter is described as a Pointer to the IUnknown of…
iPhilip
  • 43
  • 6
1
vote
1 answer

python xlrd unknown encoding: unknown_codepage_10008

I am trying to open an Excel file (.xls) using xlrd. This is a summary of the code I am using: def import_excel(key): key_url = os.path.join(UPLOAD_DIR, key) data = xlrd.open_workbook(key_url) table = data.sheets()[0] nrows = table.nrows ncols =…
loopbing
  • 35
  • 7
1
vote
1 answer

COM IUnknown and do I need a pointer to it first before calling CoGetClassObject?

In COM, when you want to create an instance of some COM Server object, do you first need to get a pointer to it's IUnknown interface and only then create a class object using CoGetClassObject? As far as I understand it, IUnknown is used to manage…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415