com

Use SHAssocEnumHandlers in C#

折月煮酒 提交于 2019-12-02 06:06:56
I am struggling to call the WinAPI SHAssocEnumHandlers in C#. using System; using System.Runtime.InteropServices; namespace AssocHandlerTest { [Flags] public enum ASSOC_FILTER { ASSOC_FILTER_NONE = 0x0, ASSOC_FILTER_RECOMMENDED = 0x1 }; [ComImport] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("F04061AC-1659-4a3f-A954-775AA57FC083")] public interface IAssocHandler { int GetName([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppsz); int GetUIName([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppsz); int GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] out string

Loading and Passing JScript Arrays from/to C# (not C) COM Component

耗尽温柔 提交于 2019-12-02 06:06:38
I have looked at tutorials on jscript arrays, but not seeing it yet. I saw something similar asked but involving Win32 code not .NET. Wondering, how do I pass arrays back and forth between JScript and a C# COM component? For example, I have two properties defined in my C# COM that returns string and integer arrays as: string[] HeaderLines { get; set; } int[] ImagePixels { get; set; } In my test.js file: ... var T = new ActiveXObject("Imager.Reader"); ... var headerLines = T.HeaderLines; WScript.StdOut.WriteLine("First HeaderLine:" + headerLines[0]); var pixels = T.ImagePixels; WScript.StdOut

Why isn't my IE MIME filter being created or called?

百般思念 提交于 2019-12-02 05:55:20
问题 I'm trying to create a MIME filter to do some custom processing of resources received with web pages before passing them to the web browser control in our Windows application. The application is written in C#, and I'd like to write the MIME filter in managed code as well, if possible. I'm having trouble with it though: my filter object doesn't seem to be getting called at all. Here's my code. Sorry it's so long, but I think I might be defining something incorrectly in the COM interfaces, so I

Including Microsoft Office Spell Checker in own application

强颜欢笑 提交于 2019-12-02 05:50:59
I heard a while ago that the Microsoft Office Spell Checker could be included in own application by using the COM interface of it. Someone remembers the details? Which dll, or which ActiveX Object was it? I have been investigating this just a month ago. It seems that it was possible, but if I remember well since Office 2003 the embeddable COM component has been removed. You will have to look for older versions if you want to do so. Unfortunately I don't have any link, but it took me few minutes to find the appropiate explanations in Microsoft forums. I have been evaluating some commercial

dynamic_cast of a COM object to a COM interface doesn't bump the reference count, does it?

喜欢而已 提交于 2019-12-02 05:46:43
问题 If I have a C++ class, X, which implements the COM interfaces IY and IZ, and I have a pointer y to the IY interface of an object of type X, and I do this: IZ *z = dynamic_cast<IZ *> ( y ); That doesn't bump the object's reference count, does it? I don't have to do a Release() to account for it, right? If it matters, I'm using ATL/COM. I'm guessing the answer is "no it doesn't bump the reference count, and no you don't have to Release()", but I want to make sure. Thanks in advance. 回答1:

How would I do TDD with a COM OLE object

喜欢而已 提交于 2019-12-02 05:00:49
问题 I have an OLE COM object that trying to write a wrapper for, I have decided to start to use TDD to write the code for it as I believe that it will give me a better sense of direction with what I'm try to write. The COM object has a interface like this: Interface Mapinfo Sub [Do](ByVal cmd As String) Function Eval(ByVal cmd As String) As String End Interface The [Do] command would take somthing like the following Mapinfo.Do("OpenTable("""C:\Temp\MyTable.TAB""")") Now I am trying to write a

Class not registered

ぐ巨炮叔叔 提交于 2019-12-02 04:57:06
I'm working through "Developer's Workshop to COM and ATL 3.0" by Andrew W. Troelsen. I'm trying to implement the lab in Chapter 3. It shows you how to build a COM client to connect to an inprocess COM server that was developed in an earlier lab. When I run the client, I receive the error "Class not registered" when calling 'CoGetClassObject'. Here is a snippet of code: // Get the class factory pointer of CoCar. hr = CoGetClassObject(CLSID_CoCar, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory, (void**)&pCF); if(SUCCEEDED(hr)) { // Make a CoCar & get ICreateCar hr = pCF->CreateInstance(NULL, IID

How to programmatically register (set correct path to) a type library from within .NET?

房东的猫 提交于 2019-12-02 04:51:03
问题 Using .NET 4.0, I have made a COM-enabled DLL (let's call it example.dll), and I have registered it and generated the respective type library using regasm.exe (regasm.exe /tlb /codebase example.dll); the type library is called example.tlb. The assembly is strongly named. This works so far, and I can use the DLL and the TLB from within VBA. But for certain reasons, I need to make my own utility which does the DLL registration and TLB generation. Basically, this utility will be in the same

Does .NET define common HRESULT values? [duplicate]

匆匆过客 提交于 2019-12-02 04:32:19
This question already has an answer here: HRESULT Enumeration C# 4 answers I'm creating a COM class in C#, which will be called from unmanaged C++. I want to use ThrowExceptionForHR but I'd rather not have to hard-code HRESULT numeric values. I was expecting there would be some enum of common HRESULT values in .Net somewhere? Put another way, where can I find named symbols which map to HRESULT values to pass into ThrowExceptionForHR ? Update: MS talk about it in this page: HRESULT Information in Managed Code . They reference VSConstants class Microsoft.VisualStudio.VSConstants but when I try

Registration-free Interop between a 64-bit COM dll and a C#/.Net application

痞子三分冷 提交于 2019-12-02 04:31:18
I am trying to get registration-free COM interop between a 64-bit COM dll and a C# app to work. In the answers to a previous question of mine , I got help that allowed me to successfully call a HelloWorld method on the 64-bit COM dll for C#. However, this was only possible by registering the COM dll globally using regsrv32.exe. Based on this answer to a related question, I think that I need to set the Isolated flag on the reference of the COM dll to true. However, this leads to the following build error: Problem isolating COM reference 'ComLibInteropLib': No registered classes were detected