com

Calling Shell32.dll from .NET Windows Service

☆樱花仙子☆ 提交于 2019-12-19 05:35:07
问题 I have a .NET 4.0 library that uses Shell32 and Folder.GetDetailsOf() to get metadata from WTV files. I have used it successfully with Console and Windows Forms apps without issue. But for some reason, when calling the component from a .NET 4.0 Windows Service, the call to initiate the Shell class causes a COM error. The code that fails inside the library: Shell32.Shell shell = new Shell(); The error: Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell32.Shell'.

How to iterate through SAFEARRAY **

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 05:33:10
问题 how to iterate through C++ safearray pointer to pointer and access its elements. I tried to replicate the solution posted by Lim Bio Liong http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/022dba14-9abf-4872-9f43-f4fc05bd2602 but the strangest thing is that the IDL method signature comes out to be HRESULT __stdcall GetTestStructArray([out] SAFEARRAY ** test_struct_array); instead of HRESULT __stdcall GetTestStructArray([out] SAFEARRAY(TestStruct)* test_struct_array); Any ideas?

How to best convert VARIANT_BOOL to C++ bool?

痴心易碎 提交于 2019-12-19 05:05:35
问题 When using COM boolean values are to be passed as VARIANT_BOOL which is declared in wtypes.h as short . There are also predefined values for true and false : #define VARIANT_TRUE ((VARIANT_BOOL)-1) #define VARIANT_FALSE ((VARIANT_BOOL)0) Which is the best way to convert from VARIANT_BOOL to C++ bool type? Obvious variants are: compare with VARIANT_FALSE simply cast to bool Other ways can be easily invented. Which is the best way to do this - most readable, most standart-compliant, least prone

Registering my .net assembly for COM interoperability doesn't expose my methods

◇◆丶佛笑我妖孽 提交于 2019-12-19 04:05:28
问题 Ok, I'm going crazy. I've been trying to make a simple .net assembly visible to use as a COM object but it's not working. I've been trying a lot of different aproaches but none of them work. So far the closest i've got is the one with the least amount of attributes, interfaces, manually registering etc. I have a vbscript as a test which looks like this: Dim o o = CreateObject("MyNamespace.MyClass") msgbox o.Test() My c# code looks like this: using System; using System.Runtime.InteropServices;

How to create a IDirect3DSurface from an IBuffer or byte array in UWP

依然范特西╮ 提交于 2019-12-19 04:04:10
问题 I want to create a video from a few RenderTargetBitmap s in UWP. I am doing that by using MediaClips . From RenderTargetBitmap i can get an IBuffer or byte array of pixels. To create a MediaClip I need either an image file or an IDirect3DSurface . Creating an image just to create a clip is very expensive, so I thought of using IDirect3DSurface . How can I do this? I have tried this: RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync

How to create a IDirect3DSurface from an IBuffer or byte array in UWP

霸气de小男生 提交于 2019-12-19 04:04:05
问题 I want to create a video from a few RenderTargetBitmap s in UWP. I am doing that by using MediaClips . From RenderTargetBitmap i can get an IBuffer or byte array of pixels. To create a MediaClip I need either an image file or an IDirect3DSurface . Creating an image just to create a clip is very expensive, so I thought of using IDirect3DSurface . How can I do this? I have tried this: RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync

What is required to enable marshaling for a COM interface?

旧时模样 提交于 2019-12-19 03:59:20
问题 I have a 32-bit ATL COM component without a type library. It has a class factory for one given class that implements several interfaces. When I use it as an in-proc server, everything works fine - the client side invokes CoCreateInstance(), the object is instantiated and QueryInterface() retrieves a pointer to a requested interface. But when I put the component into COM+ I no longer can instantiate the class - CoCreateInstance() now returns E_NOINTERFACE. I believe the problem is that COM+

shared_ptr vs CComPtr

蓝咒 提交于 2019-12-19 03:56:19
问题 I'm somewhat used to the concept of refcounting through COM and I'm somewhat new to shared_ptr. There are several nice properties with CComPtr that I don't find in shared_ptr, and I'm wondering what are the pattern that prevent missuse of shared_ptr. The AddRef/Release pattern guarantees there is only one refcount per object (the refcount is stored on the object itself), so it's safe, when you have a random pointer to create a CComPtr around it. On the other hand, shared_ptr has a separate

Passing arrays from VBA to VB.NET

狂风中的少年 提交于 2019-12-19 03:53:11
问题 I am working on a vb.net COM interop to work in Microsoft Excel and I am having trouble passing arrays from vb to vb.net. I have a PointPairs property in the vb.net code that I need to set from vb and I am having trouble passing the 2 dimensional array. I have tried both setting the property explicitly with a 2D array as well as passing two 1D arrays into a Sub to try and set the property in vb.net, but nothing I have tried seems to work. vb.net code: Public Property PointPairs() As Double(,)

Exposing COM events to VBScript (ATL)

若如初见. 提交于 2019-12-19 03:38:18
问题 I have built a COM server DLL in C++ with ATL by using the "ATL simple object" wizard. I followed Microsoft's ATLDLLCOMServer example. Everything works well except for one thing: I do not receive COM events in VBScript . I do receive the events in C#. I had events working in VBScript in an earlier MFC-based implementation as ActiveX control. My control is defined like this: class ATL_NO_VTABLE CSetACLCOMServer : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass