com

Understand COM c# interfaces

谁说我不能喝 提交于 2019-12-04 05:52:56
The Microsoft.Office.Interop.Word._Document interface has a method with the following signature: void Close(ref object SaveChanges = Type.Missing, ref object OriginalFormat = Type.Missing, ref object RouteDocument = Type.Missing); A few points I am having trouble understanding: A ref parameter cannot have a default value. A default value has to be a constant, and Type.Missing is not. When calling this method, I can use Close(false) - normally a ref parameter requires an assignable variable? When navigating to the definition of Type in Visual Studio, it takes me to the _Document.Type property,

How to add(enable) standard “Send To” context menu option in a namespace extension

拟墨画扇 提交于 2019-12-04 05:50:56
问题 I have a namespace extension, which provides a virtual view of files/folders in a server. In the IContextMenu::QueryContextMenu() I have added some of the custom menu items. I have also set couple of SGAOF flags in the IShellFolder::GetAttributesOf() to get the rename, delete, and properties, in the context menu. Is there any way I can get the " Send To " option in the context menu for items in my namespace extension? and How do I handle these commands once these are enabled?. Please advise.

Implementing IDispatch in c#

烈酒焚心 提交于 2019-12-04 05:32:01
I'm writing some test code to emulate unmanaged code calling my c# implementation of a late binding COM object. I have an interface that is declared as an IDispatch type as below. [Guid("2D570F11-4BD8-40e7-BF14-38772063AAF0")] [InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface TestInterface { int Test(); } [ClassInterface(ClassInterfaceType.AutoDual)] public class TestImpl : TestInterface { ... } When I use the code below to call IDispatch's GetIDsOfNames function .. //code provided by Hans Passant Object so = Activator.CreateInstance(Type.GetTypeFromProgID("ProgID.Test"));

Control 2 separate Excel instances by COM independently… can it be done?

痞子三分冷 提交于 2019-12-04 05:26:09
I've got a legacy application which is implemented in a number of Excel workbooks. It's not something that I have the authority to re-implement, however another application that I do maintain does need to be able to call functions in the Excel workbook. It's been given a python interface using the Win32Com library. Other processes can call functions in my python package which in turn invokes the functions I need via Win32Com. Unfortunately COM does not allow me to specify a particular COM process, so at the moment no matter how powerful my server I can only control one instance of Excel at a

Why does this implementation of COM IUnknown::Release work?

有些话、适合烂在心里 提交于 2019-12-04 05:23:59
From examples I've seen COM IUnknown::Release() function implementation is something like that: ULONG Release() { InterlockedDecrement(&m_count); if(m_count == 0) { delete this; } return m_count; } So, if m_count is 0, so we're deleting "this" object, and returning the ref count. What I don't understand is why it works ?!?! Deleting the object wouldn't ruin the call stack or is it okay because it is being held by the thread, so it has nothing to do with the object ??? If the object has been deleted, how is it possible that we can return m_count, it should've been deleted. I could have

How to release COM objects in Silverlight 4

谁都会走 提交于 2019-12-04 05:23:48
When using COM Interop with Office (usually Excel), I always carefully ensure I call Marshal.ReleaseComObject on every reference, to avoid the problem where Excel doesn't quit as described in this KB article . How can I ensure Excel quits when I use Interop from an OOB Silverlight application (with AutomationFactory.CreateObject )? Silverlight doesn't have a Marshal.ReleaseComObject method and even calling GC.Collect and GC.WaitForPendingFinalizers doesn't help. Surely Microsoft hasn't added this feature to Silverlight without a mechanism to release COM references? This seems to me to be a

Implement a C# DLL COM File In Unmanaged C++ Program

柔情痞子 提交于 2019-12-04 05:12:07
问题 Here is my other question that led into this one as reference also: How to call managed C++ methods from Un-managed C++ I have successfully created a C# COM File. Now I need a simple explanation on how to implement it in unmanaged C++. I am following this example but the c++ part is weak. http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C Here is my COM file using System; using System.Runtime.InteropServices; using System.Collections.Generic; using System.Linq; using System

How to Pass Byte Arrays as UDT Properties from VB6/VBA to C# COM DLL?

◇◆丶佛笑我妖孽 提交于 2019-12-04 05:05:33
问题 I have a C# library that I'm trying to expose to VBA. I can pass parameters to functions just fine (ie "ref byte[] someArray"), but passing objects or structs just won't work. If I try passing a byte array as a property of a class, I get the following error in VB- Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic If I try passing a byte array as a property of a struct, I get the following error in VB- I've been fighting this for

Is there a document on .rgs files syntax?

穿精又带淫゛_ 提交于 2019-12-04 04:54:10
Resource scripts loaded from .rgs files are used with ATL CComModule::UpdateRegistryFromResource() . It's quite common to see samples of such files on the net but I've never seen a complete description on what constructs are allowed in .rgs files. Is there such a document? There's some MSDN documentation , but it appears to be pretty unfocused. The book ATL Internals talks at some length about custom replacements. Other than that, I haven't seen much... 来源: https://stackoverflow.com/questions/1594283/is-there-a-document-on-rgs-files-syntax

32 and 64 bit interoperability on 64-bit Windows

百般思念 提交于 2019-12-04 04:41:07
Is there a good thorough authoritative reference that discusses interoperability between 32-bit and 64-bit processes? Based on googling I have deduced that: A 32-bit DLL can only reside in a 32-bit process, and a 64-bit DLL only in a 64-bit process. 32 and 64-bit processes can only communicate using loosely coupled message systems, such as network communications, which means they can communicate using COM/DCOM. 32 and 64-bit COM components have different registry entries. A component is typically only registered in one of the two and typically only seen in one of the two worlds. A 32-bit