com

C# How do you get an instance of a COM interface

和自甴很熟 提交于 2019-12-04 17:18:19
I've been doing quite a bit of googling trying to find the standard way to get an instance of a COM interface. Microsoft provides an example of this in their article COM Interop Part 1: Client Tutorial : // Create an instance of a COM coclass: FilgraphManager graphManager = new FilgraphManager(); // See if it supports the IMediaControl COM interface. // Note that this will throw a System.InvalidCastException if // the cast fails. This is equivalent to QueryInterface for // COM objects: IMediaControl mc = (IMediaControl) graphManager; // Now you call a method on a COM interface: mc.Run();

Printing in Duplexpage a word document

给你一囗甜甜゛ 提交于 2019-12-04 17:11:31
I am trying to automate the task of printing two copies at double page of ~30 Word document (*.doc). I want to send the program converted to .exe (I plan it just for Windows computers) using py2exe . I know that I can manually check the options but I will not be able to do so on the 20 or so computer where it will be used, as well as I cannot install in this computers new software (That's why I want to convert it into .exe ). I copied this solution to print, but I can't adapt it to do what I want: from win32com import client import time word = client.Dispatch("Word.Application") filename=input

Get iplImage or Mat from directshow to opencv

放肆的年华 提交于 2019-12-04 16:59:24
I had to change to directshow for my eyetracking software due to the difficulties to change resolution of the camera when using c++ and opencv. Directshow is new to me and it is kind of hard to understand everything. But I found this nice example that works perfectly for capturing & viewing the web cam. http://www.codeproject.com/Articles/12869/Real-time-video-image-processing-frame-grabber-usi I am using the version that not requires directShow SDK. (But it is still directshow that is used in the example, right??) #include <windows.h> #include <dshow.h> #pragma comment(lib,"Strmiids.lib")

What is the difference between AxInterop and Interop?

 ̄綄美尐妖づ 提交于 2019-12-04 16:58:13
问题 I've added an .ocx to the toolbox in VS. Two .dll's were created: Interop.NNN.dll, AxInterop.NNN.dll. What is each one? Are they both required? 回答1: The AxFoo.dll assembly contains an automatically generated class that's derived from the System.Windows.Forms.AxHost control. It is pretty simple, it has methods, properties and events, the same ones you have available in the .ocx, that simply call the Foo.dll interop library. So, yes, you definitely need to deploy both assemblies. 回答2: Interop

How to write simple background thread in CWorkerThread

孤街醉人 提交于 2019-12-04 16:37:51
I'm trying to asynchronously run function in my add-on for Internet Explorer (I'm writing BHO in VC++). As suggested here I'm trying to use CWorkerThread. I've been trying to figure it out for hours but still have no idea how to do it. I don't have much experience in ATL. The lack of a good documentations or tutorials on Internet is killing me. I'm creating class by Add->Class and choosing ATL Simple Object (that's how you add classed to ATL project right?). But how to implement this IWorkerThreadClient? I thought that choosing Add->Implement Interface in Class View would be good but there is

Is it possible to forward delegate through COM interop?

妖精的绣舞 提交于 2019-12-04 16:37:09
I have a class: public class A { public delegate void SetTextDel(string value); public void Test() { SetTextDel setText = someInterface.SetText; icom.Set(setText); } } [ComVisible(true), Guid("81C99F84-AA95-41A5-868E-62FAC8FAC263"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface Icom { void Set(Delegate del); } [ComVisible(true)] [Guid("6DF6B926-8EB1-4333-827F-DD814B868097")] [ClassInterface(ClassInterfaceType.None)] [ComDefaultInterface(typeof(Icom))] public class B : Icom { Set(Delegate del) { del.DynamicInvoke("some text"); } } And I get targetinvocation exception in Set

How do I go about instantiating a COM Object in C# by CLSID?

霸气de小男生 提交于 2019-12-04 16:03:15
Forgive me if my terminology is off, as this is somewhat uncharted territory for me. I have a program which needs to create a FolderShortcut . Microsoft has documentation on how to create it in C++, and I'm trying to translate the directions to C#. The instructions state that the CoCreateInstance function needs to be called with CLSID_FolderShortcut as a parameter, which I infer to mean that it's instantiating a COM object. The CLSID for this object is {0AFACED1-E828-11D1-9187-B532F1E9575D} . I've tried adding a reference to Shell32.dll from the COM tab, but the FolderShortcut object does not

C# Visual Studio: How to have multiple developers on a solution that references Office?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 15:43:20
When I add a reference to Office COM Library, I to go: References Add Reference Select the COM tab Select Microsoft Office 12.0 Object Library And magically named reference appears: Microsoft.Office.Core The Project.csproj file shows the details of the reference: <COMReference Include="Microsoft.Office.Core"> <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid> <VersionMajor>2</VersionMajor> <VersionMinor>4</VersionMinor> <Lcid>0</Lcid> <WrapperTool>primary</WrapperTool> <Isolated>False</Isolated> </COMReference> i check the project into source control, and now nobody else can build the

Compiling VB6 app w/ .NET interop, only runs if compiled on my machine

ぃ、小莉子 提交于 2019-12-04 15:42:30
I recently developed an interop user control in .NET (Visual Studio 2008, project targetting .NET 2.0) to be used in a VB6 application. The assembly exposes 1 control, 1 class, and a few enums and structs. I developed it using C# translations of the Interop Forms Toolkit 2.0 project template found here . The assembly has a strong name and gets installed in the GAC and registered with regasm with the following script: @"C:\gacutil.exe" /i "C:\Program Files\AppName\Control.dll" /f @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe" "C:\Program Files\AppName\Control.dll" /tlb:"C:\Program

System.Windows.Forms.Timer not firing

时光怂恿深爱的人放手 提交于 2019-12-04 15:21:54
I want to use a System.Windows.Forms.Timer to ensure that an event fires on the UI thread of an excel addin I'm creating. I construct the timer as follows: private System.Windows.Forms.Timer _timer; private void ThisAddIn_Startup(object sender, System.EventArgs e) { Debug.WriteLine("ThisAddIn_Startup:" + Thread.CurrentThread.ManagedThreadId); _timer = new System.Windows.Forms.Timer(); _timer.Tick += new EventHandler(TimerEventHandler); _timer.Interval = 500; } The timer is fired by a COM event from a library I am using: private void OnEvent() { _timer.Start(); } I then expect the _timer to