com

How to get process handle of a local COM server?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 04:23:50
问题 I have an IUnknown pointer to a COM local (out of process) server in my Windows client application. Would like to get a handle to the window process that is running the local COM server. Any way to do this via COM without adding a new interface to the server to request the process handle? (I can't easily change the server). Why do I want to do this? Because I am trying to make sure the out-of-proc COM server gets shutdown IF my application crashes. I wanted to use windows job objects for this

Under what conditions is CCmdTarget::OnFinalRelease called?

自闭症网瘾萝莉.ら 提交于 2019-12-02 04:23:43
问题 The MSDN documentation for the CCmdTarget::OnFinalRelease method is pretty brief: Called by the framework when the last OLE reference to or from the object is released. I have created a sub-class of CCmdTarget class CMyEventHandler : public CCmdTarget { ... } I'm trying to figure out under what conditions the OnFinalRelease method will be called. I have some code that looks something like this: CMyEventHandler* myEventHandler = new CMyEventHandler(); LPUNKNOWN pUnk = myEventHandler-

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

拈花ヽ惹草 提交于 2019-12-02 04:01:52
问题 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 GetPositionType(); } The implementation of the public class Order : IOrder is just three private fields and a constructor with required 3 parameters. Somewhere else, I have the following method with a result with which I want to work inside a C++ unmanaged code,

Wrapping a COM object/dynamic type in C#

笑着哭i 提交于 2019-12-02 03:55:54
I am currently working with COM objects in managed code and am using the new dynamic type for this. This works well in some areas but can be an issue in others. I was think about how I could get the best of both worlds, the flexibility of the dynamic type (late bound) with the support for say, an RCW (early bound) Somehow wrapping the dynamic type in a more manageable stucture. I was wondering if there was a preferred method for this (if it is even a good idea) or what things I should consider. The two basic ideas I came up with so far as follows: Firstly, creating a static class that allows

Why would QueryInterface() fail when the interface is surely implemented and has built-in marshaller in Windows?

让人想犯罪 __ 提交于 2019-12-02 03:35:24
I have the following setup. There's a COM server that is installed into COM+ (to run in a separate process) and has this interface definition: [object, uuid("InterfaceIdHere"), nonextensible, oleautomation, hidden] interface IMyInterface : IUnknown { HRESULT MyMethod( [in] IUnknown* param ); }; The caller calls it like this: HRESULT callComObject(IStream* stream) { return comObject->MyMethod(stream); } Note that here IStream* is implicitly upcasted to IUnknown* . This is done because declaring a parameter of type IStream* in IDL caused some problems that I can't recall right now. Anyway it's

Calling C# COM object

泪湿孤枕 提交于 2019-12-02 03:34:59
Ok, I've created a c# dll, made all its interface and methods all ComVisible(true). Added it to the GAC using gacutil, then registered it using regasm and created a type library tlb file. Now I have another c# project that I want to make calls to that com object, how can I do this? What would the code roughly look like to import the com object then use its calls? First of all, why do you want to call that C# Assembly (that you've made comvisible) in your other C# project via COM ? That is not necessary ... Ontopic: If you've created a tlb file, then you shouldn't do anything special. You can

VBScript “Type Mismatch” issue with “[in, out] BSTR * ” parameter

谁说胖子不能爱 提交于 2019-12-02 03:31:10
问题 I'm working with third-party COM object that has some of its methods passing values back as BSTR pointer. Since VBscript supports only Variant type attempts to use in a way like Object.Method(sMyString) reasonably end with "Type mismatch" error. I suspect this error is generated by the COM object itself rather then VBscript interpreter since the object gets string instead of pointer. I tried to workaround it defining array of strings but it's still the same error. So I was wondering if

How to properly call IDispatch::Invoke with a required BSTR* parameter

六眼飞鱼酱① 提交于 2019-12-02 02:49:30
问题 There are many examples of how to call IDispatch::Invoke with a BSTR* parameter. I have this working with many other "SomeType*" parameter but no matter what I try, I either get HRESULT of Type Mismatch, E_OUTOFMEMORY or an access violation. It seems to me I am doing something wrong with memory but I am following the different examples I have found... As a side note, the final "[out] UINT puArgErr" argument is never filled with the argument index that is causing the problem. However, I know

Why does TypeName() return different results from .GetType and TypeOf when working with COM?

陌路散爱 提交于 2019-12-02 02:21:56
问题 I feel like I would benefit greatly from understanding the differences in how these functions work so that I could better understand when to use each one. I'm having a very difficult time working with two different interops (Excel, and EPDM) which have both made extensive use of weak typed parameters. I keep running into problems using returned objects and casting them to the proper type (per the documentation). After wasting a ton of time, I've found that using TypeName, GetType, and a

How to get process handle of a local COM server?

随声附和 提交于 2019-12-02 02:17:43
I have an IUnknown pointer to a COM local (out of process) server in my Windows client application. Would like to get a handle to the window process that is running the local COM server. Any way to do this via COM without adding a new interface to the server to request the process handle? (I can't easily change the server). Why do I want to do this? Because I am trying to make sure the out-of-proc COM server gets shutdown IF my application crashes. I wanted to use windows job objects for this. I assume you mean an out-of-process server. No, COM is heavily invested in preventing you from