Questions tagged [queryinterface]
31 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
12
votes
4 answers
How to get the id (memory address) of dll-function?
I want to use a function from nvapi in C# "NvAPI_DRS_EnumProfiles".
I have to call QueryInterface(id) with the id of the function.
Everything is working fine and i found the ids for the other functions i need on the web,
but i can't find the id of…

MaxPower
- 141
- 1
- 5
11
votes
3 answers
Why is every successful QueryInterface() call followed by Release() call?
Why is a QueryInterface() call always followed by a Release() call? For example, I have seen a sample code from MSDN as below:
HRESULT hr = S_OK;
CDecoder *pObj = new CDecoder(&hr);
if (SUCCEEDED(hr))
{
*ppv = NULL;
hr =…

Arun Reddy Kandoor
- 203
- 1
- 2
- 10
10
votes
3 answers
How do Powershell query interface on a COM object
I created a COM object using Powershell:
$obj = new-object -com MyLib.MyObj
Then I need to query the interface "MyLib.MyInterface" on that object, but I have no idea how to do it with PowerShell.
In other words suppose I have the below C++…

Shuping
- 5,388
- 6
- 43
- 66
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
4
votes
2 answers
What is IconnectionPoint and EventHandling
Trying to understand What is IConnectionPoint and how this is connected to IConnectionPointContainer,IEnumConnectionPoints,IEnumConnections and EventHandling.
Read the artcicles from MSDN and CodeProject which is explaining a about other methods…

Simsons
- 12,295
- 42
- 153
- 269
4
votes
1 answer
InvalidCastException, QueryInterface call failing on COM component
I'm trying to use PCAnywhere's Ole automation in a .net applicaction I'm currently developing (VS 2010, c#). PCA 12.5 comes with a couple tlb files that when I try to add as references through VS I get an error on both saying 'A reference to…

rhyek
- 1,790
- 1
- 19
- 23
4
votes
2 answers
Handling CoCreateInstance return value
Here's a code sample creating a COM object:
CComPtr pFilter;
auto hr = CoCreateInstance(CLSID_DMOWrapperFilter, NULL,
CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast(&pFilter));
I've seen somewhere that checking if…

Dalamber
- 1,009
- 1
- 12
- 32
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
1 answer
How can I do a Custom QueryInterface for .NET 3.5?
I have .NET Assembly exposed to COM, and I want to create a custom QueryInterface, otherwise my Class will have to implement a lot of interfaces.
Currently my implementation is like…

Pablo Retyk
- 5,690
- 6
- 44
- 59
3
votes
1 answer
Porting comtypes to win32com
In a Python script I have to replace usage of comtypes by win32com and pythoncom. Essentially I have this code:
from comtypes.client import CreateObject, GetEvents
object_IXXObjManager = comtypes.client.CreateObject(xxxId)
connection_IXXObjManager…

skotka
- 169
- 1
- 6
3
votes
2 answers
Get IID from interface name in C++? (VS 2010 automation)
Given the name of a COM interface as a string, how do I get the corresponding IID so that I can call QueryInterface()?
For example:
// Attempt to cast IDispatch referenced by pDisp to an ICommandBarButton
char *interface_name =…

Chungzuwalla
- 1,038
- 6
- 17
3
votes
1 answer
E_NOINTERFACE while trying to get a class method pointer
I'm calling the C# methods from a C++ unmanaged code. I have a problem with getting a value from a class instance returned in array.
I've simplified the code a little bit
This is the problematic method.
[return:…

Mirek
- 4,013
- 2
- 32
- 47
3
votes
2 answers
C# - object casting
As far as I know, if we're dealing with COM interfaces, any simple cast will usually trigger the QueryInterface routine, which is used to determine if the object actually implements the corresponding COM interface.
object whatever;
IComInterface…

Yippie-Ki-Yay
- 22,026
- 26
- 90
- 148
2
votes
1 answer
Using the RFCOMAPIlib (RightFax COM API): Unable to cast COM object
I'm working with the RightFax COM API. What I want to do is simply send a fax with an attachment. Simple right? That question has been answered a few times. However, when I use some of that code in my application, I have a little…

Erik
- 23
- 1
- 3