interop

How to enumerate word document using office interop API?

点点圈 提交于 2020-01-24 12:25:06
问题 I want to traverse through all the elements of an word document one by one and according to type of element (header, sentence, table,image,textbox, shape, etc.) I want to process that element. I tried to search any enumerator or object which can represent elements of document in office interop API but failed to find any. API offers sentences, paragraphs, shapes collections but doesnt provide generic object which can point to next element. For example : <header of document> <plain text

Rust interop with C++ std::string

送分小仙女□ 提交于 2020-01-24 03:30:26
问题 I'm trying to build Octave functions in Rust. Octave's API is in C++, so I've generated bindings using rust-bindgen. I'm currently working through the problems that occur when trying to generate bindings that include std::string. It would be nice if I could leave it opaque and valid pointer to a C++ std::string. Would it be possible to build a utility function on the C++ side any time I needed to pass in a C++ std::string ? I was naive when I first attempted this. It is clearly wrong. A Rust

Mixed Kotlin + Java with Maven, unresolved reference

狂风中的少年 提交于 2020-01-24 03:11:25
问题 I have a Maven project with Kotlin code hello.kt which calls Java code JavaFoo.java which calls Kotlin code KotlinFoo.kt . hello.kt also calls KotlinFoo.kt directly. I'm trying to build this with mvn clean install using exactly the Maven settings described in kotlinlang's Maven docs. If hello.kt doesn't call JavaFoo (but I leave JavaFoo in the project) then this builds just fine. The docs say that the Kotlin compiler should be invoked before the Java compiler, which suggests to me that all

How to pass string parameters between C++ and C#?

Deadly 提交于 2020-01-23 17:55:07
问题 I have imported a C++ library in my C# project. I can get the answer of a C++ method that has no parameters. What I want to do is to send some string parameters to C++ and get the result of it. In C++: public String SomeMethod(String param1, String param2) { //Some code } In C#: [DllImport("Library Path")] public static extern string SomeMethod(string param1, string param2); How can I do this? 回答1: For strings that are input parameters passed from C# to C++, you could just use LPCWSTR (i.e.

Errors when calling certain Excel VBA macros from C#

血红的双手。 提交于 2020-01-23 08:13:46
问题 I have been struggling and searching on this problem to no avail... I have a few test macros that work perfectly when run from Excel, but either fail or don't work when called from C#, using the interop... I am using MS Visual Studio 2012 (on 64 bit Windows 7) to create a console application that will call the VBA macro TestMacro() written in Excel 2007. Here is the C# code to call the macro: (I basically copied what was done here Run Office Macros by Using Automation from Visual C# .NET)

Calling unmanaged function from C#: should I pass StringBuilder or use unsafe code?

爱⌒轻易说出口 提交于 2020-01-23 06:31:08
问题 I've got a C# program that needs to pass a char buffer to an unmanaged function. I've found two ways that seem to work reliably, but I'm not sure which I should choose. Here's the unmanaged function's signature. extern "C" __declspec(dllexport) int getNextResponse(char *buffer); The first option is to define the buffer as a StringBuilder, as follows. //at class level... [DllImport("mydll.dll")] static extern int getNextResponse(StringBuilder buffer); //in main method body... StringBuilder sb

How to add multiple recipients to mailitem.cc field c#

大城市里の小女人 提交于 2020-01-23 05:01:12
问题 Oki, so im working on outlook .msg templates. Opening them programmatically, inserting values base on what's in my db. ex. when i want to add multiple reciepients at "To" field, instead of doing as following, mailitem.To = a + ";" + b + ";" + c; i do whats below, which is simpler, especially when i'm doing it in a loop. mailitem.Recipients.add("a"); mailitem.Recipients.add("b"); mailitem.Recipients.add("c"); My problem is, i also want to add multiple recipients at "CC" field and the function

Reflection on COM Interop objects

China☆狼群 提交于 2020-01-22 20:02:26
问题 Trying to create a mapper for an Microsoft Office object to POCO's and found this // doesn't work // returns an empty array where o is a RCW on an office object foreach(var pi in o.GetType().GetProperties() ) tgt.SetValue(rc, pi.GetValue(o, null)); so have to resort to this foreach(var field in tgt.GetFields() ){ var pv = o.InvokeMember(field.Name, System.Reflection.BindingFlags.GetProperty, null, o, null); i.SetValue(rc, pv); } which works for now but wondering why the RCW.GetProperties()

How to get pointer to IUnknown in C#

让人想犯罪 __ 提交于 2020-01-22 18:52:13
问题 .NET interop wraps COM objects into .NET objects (runtime-callable wrappers, RCWs), which hide the usual interface querying. In order to register a COM object representing a filter graph with the Running Objects Table, I need the (native) address of its IUnknown interface (see How can I reverse engineer a DirectShow graph?). So the question is: How can I get a COM object's IUnknown pointer in C#? 回答1: Use Marshal.GetIUnknownForObject(). 来源: https://stackoverflow.com/questions/3941349/how-to

What is Scala trying to tell me and how do I fix this? [ required: java.util.List[?0] where type ?0]

我的未来我决定 提交于 2020-01-22 15:01:29
问题 I am in the process of learning Scala and today I felt confident to introduce it to one of our projects. The application does a lot of JPA / Hibernate stuff and I started implementing one of the Java interfaces in Scala. All went well, until I tried to translate some unittest-code to Scala. I make a lot of use of Easymock, the code is quite self explanatory. I guess the problem is, that Scala does not allow me to return a typed java.util.List where it expects an untyped one. Unfortunately I