interop

Send a command to Word without GUI Automation

只谈情不闲聊 提交于 2019-12-11 19:05:32
问题 What is the preferred method to send a command to MS Word without using GUI automation to virtually click menus and buttons? I'm referring to commands that can be accessed via the GUI, such as setting font style, adding objects, adding WordArt, etc. Obviously Word.Interop allows for this, but many of the commands available in the GUI are missing or needs a bit of code to get it working exactly like the GUI command. For example, the GUI has a command to copy selected text, but that needs a

Windows Messaging - trapping calls originating from another API

六眼飞鱼酱① 提交于 2019-12-11 18:49:39
问题 Scenario: We're busy wrapping up a 3rd party's C++ SDK as a DLL to make it simpler for other developers in our organisation to integrate this functionality into their own apps (be it, .net, delphi, etc) The underlying system sends Windows messages to signal events that occur in the system. These events need to be dealt with, as they could potentially signal the state of the system and what can be done next. Question: What would the best way be to handle these messages within the context of

How to access COM vtable and acess its entries from TLB(Type Library) in C#?

允我心安 提交于 2019-12-11 18:34:16
问题 I need to access COM vtable which have entries of those functions which are exposed to outside world under some specific interface in C#. I've accessed and iterate over the types enclosed in the TLB with LoadTypeLib and playing with ITypeInfo . Now only thing I need to access one by one those methods inside vtable of COM Interface and need to call them at RUNTIME one by one. I need COM vtable address and its indexed entries (i.e function addresses). 回答1: You can create a C# wrapper from the

How to search for a particular text in the word file and Pro-grammatically change it using Word interop?

五迷三道 提交于 2019-12-11 17:55:25
问题 I need to find range of the word document starting from particular text and ends with particular text then I want to edit this range in particular format. e.g In my code I have a Table in the document whose header starts with text {TN} and Table ends with hidden text {OAEndontribution}. I want to replace text {TN} with table number and when it finds text {OAEndontribution} then it should increment table number when it finds next {TN} and this should continue. Currently I am using Word.Range

Unamanaged call is not happening from the managed C# code

牧云@^-^@ 提交于 2019-12-11 17:52:56
问题 I am calling unamanaged function from the managed code. But Unamanaged call is not happening. Managed C# code: (Created a project (Sampletest) from Visual C# -> Console App) Sampletest: namespace Sampletest { class Program { const string Dllpath2 = @"C:\Users\apc\source\repos\Sampletest\SampleDll\Debug\SampleDll.dll"; [DllImport(Dllpath2, EntryPoint = @"IsUPSPresent", CallingConvention = CallingConvention.Cdecl)] public static extern Boolean IsUPSPresent(); static void Main(string[] args) {

Using a C-callback function with .NET

早过忘川 提交于 2019-12-11 17:52:49
问题 I'm using a C-library from within .NET This all works quite nice. But I'm having troubles with a callback function. I have this C-code: Bool someCallBack(const char *name, int reason) { //some logic here return True; } int main(int argc, char **argv){ SetCallback(someCallBack) } In the header file the SetCallback is defined as: typedef Bool (*CallbackType)(const char *name, int reason); #define DLL_USE __declspec(dllimport) DLL_USE void SetCallback(CallbackType callBack); When I execute a

Interoperable way to send XML data in WCF?

岁酱吖の 提交于 2019-12-11 17:52:27
问题 I'm using System.Xml.XmlElement as a parameter for sending XML data in WCF. Is this generally the interoperable way to send XML data in WCF, so that, for example, a PHP or Java Web Service will understand it if I'll send it from a WCF Client? I've read that I should never send XML directly as string in WCF. In WSDL generated by WCF the XmlElement object is mapped to the xsd:any element in the following way: <xsd:element name="SendXMLData"> <xsd:complexType> <xsd:sequence> <xsd:element

SetWinEventHook crahes IE when used in BHO (Browser Helper Object)

主宰稳场 提交于 2019-12-11 17:39:52
问题 I have a C# BHO which sets a hook so that I can track when IE gets focus: public class BHO : IObjectWithSite, IOleCommandTarget { delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime); const uint WINEVENT_OUTOFCONTEXT = 0; const uint EVENT_SYSTEM_FOREGROUND = 3; [DllImport("user32.dll")] static extern bool UnhookWinEvent(IntPtr hWinEventHook); [DllImport("user32.dll")] static extern IntPtr

WCF Interop with WSE2.0

喜欢而已 提交于 2019-12-11 16:46:34
问题 I'm attempting, with great difficulty, to have an WCF client communicate with a WSE 2.0. The wse service requires UserName token for authentication and it would appear that this is not possible over an unsecured channel. I have configured the following custom bindings: <customBinding> <binding name="wse2Binding"> <textMessageEncoding messageVersion="Soap11WSAddressingAugust2004" /> <security authenticationMode="UserNameOverTransport"> <secureConversationBootstrap authenticationMode=

C# Excel interop merge cells in fast way

和自甴很熟 提交于 2019-12-11 16:09:16
问题 I want to merge cells and to do it multiple times... The reason I'm using this merge its because I want more the one table. and a different number of columns for each table and different size of a column on the another... The number and the places of the merges are unknown using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp111 { class Program {