interop

c# MSOffice Interop Word will not kill winword.exe

可紊 提交于 2019-11-30 01:43:54
问题 I'm writing an application that needed a MSWord document parser. I'm using Microsoft.Office.Interop.Word.Document to extract the texts from the documents, but even if i use doc.Close() the document, from taskManager i can see that winword.exe are not killed, and after parsing a couple dozens documents it eats up some much resources. is close() the wrong method? please help me and point me to the right direction on how to terminate these processes properly. =) ~~~update~~~ Thanks for all the

64 to 32 bit Interop - how?

南楼画角 提交于 2019-11-30 01:25:28
问题 I need to integrate some legacy 32-bit code - for which I don't have the source code, into a project in such a way that it can be called from a 64-bit .NET assembly. The original code is implemented as a 32-bit COM object in a DLL. Windows doesn't allow direct calls from 64 to 32-bit objects, so I'm looking for inspiration on how to deal with this situation. How can a legacy 32-bit COM object be accessed from a 64-bit .NET assembly? UPDATE: We discovered that the COM component was itself a

Accessing scala object fields from java

∥☆過路亽.° 提交于 2019-11-30 01:09:34
问题 I'm having trouble accessing the fields of a scala object from java. Scala: object TestObject { val field = 5 } Java: public class JavaTest { public static void main(String[] args) { int i = TestObject.field; } } Error: [error] JavaTest.java: cannot find symbol [error] symbol : variable field [error] location: class TestObject [error] int i = TestObject.field; 回答1: Scala fields are private variables with a getter of the same name to preserve immutability. public class JavaTest { public static

How to create a COM object in a UWP application? (C#)

一曲冷凌霜 提交于 2019-11-30 00:44:25
Question: How to create COM object in a Universal Windows Platform (UWP) application? Motivation: I want to switch from WPF to UWP. Since my workload requires making calls to third-party libraries accessible only through COM (so far as I know), I need to make COM calls from UWP. Context: C# .NET Visual Studio 2015 Windows 10 Ideally targeting all UWP devices, but okay if restricted to desktops/laptops. Background In Visual Studio 2013 ("Classic Desktop" project in Visual Studio 2015), I used the C# code // Conceptual: DotNetInterface comObjectInstance = (DotNetInterface)Microsoft.VisualBasic

Capturing data from a window in a closed-source third-party Win32 application

三世轮回 提交于 2019-11-29 23:06:50
问题 I'm planning on creating a C# Windows Forms app as an extension for a third-party Win32 application but I'm stumped as to how to do this right now. The farthest I've gotten is knowing it involves Win32 Hooking and that there's this open source project called EasyHook that's supposed to allow me to do this. I'd like to know how I can get the text from a textbox or some other data from a control in a third-party Win32 application. The text/data in a control is to be captured from the external

How do I create an JS Object with methods and constructor in ClojureScript

我的未来我决定 提交于 2019-11-29 22:39:11
Imagine the task is to create some utility lib in clojurescript so it can be used from JS. For example, let's say I want to produce an equivalent of: var Foo = function(a, b, c){ this.a = a; this.b = b; this.c = c; } Foo.prototype.bar = function(x){ return this.a + this.b + this.c + x; } var x = new Foo(1,2,3); x.bar(3); // >> 9 One way to achieve it I came with is: (deftype Foo [a b c]) (set! (.bar (.prototype Foo)) (fn [x] (this-as this (+ (.a this) (.b this) (.c this) x)))) (def x (Foo. 1 2 3)) (.bar x 3) ; >> 9 Question: is there more elegant/idiomatic way of the above in clojurescript?

C#: marshalling a struct that contains arrays

二次信任 提交于 2019-11-29 20:10:59
问题 I am doing some C# interop work. I have the following struct: #pragma pack(push,1) typedef struct { unsigned __int64 Handle; LinkType_t Type; LinkState_t State; unsigned __int64 Settings; signed __int8 Name[MAX_LINK_NAME]; unsigned __int8 DeviceInfo[MAX_LINK_DEVINFO]; unsigned __int8 Reserved[40]; } LinkInfo_t; This is my attempt to convert it into a C# struct: [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct LinkInfo_t { [MarshalAs(UnmanagedType.U8)] public UInt64 Handle;

Marshal C++ “string” class in C# P/Invoke

早过忘川 提交于 2019-11-29 19:51:37
问题 I have a function in a native DLL defined as follows: #include <string> void SetPath(string path); I tried to put this in Microsoft's P/Invoke Interop Assistant, but it chokes on the "string" class (which I think is from MFC?). I have tried marshaling it as a variety of different types (C# String, char[], byte[]) but every time I either get a NotSupportedException or a Native Assembly Exception (depending on what marshaling I tried). As anyone ever done Native/Managed Interop where the native

What is the size of a boolean In C#? Does it really take 4-bytes?

江枫思渺然 提交于 2019-11-29 19:13:18
I have two structs with arrays of bytes and booleans: using System.Runtime.InteropServices; [StructLayout(LayoutKind.Sequential, Pack = 4)] struct struct1 { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] values; } [StructLayout(LayoutKind.Sequential, Pack = 4)] struct struct2 { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public bool[] values; } And the following code: class main { public static void Main() { Console.WriteLine("sizeof array of bytes: "+Marshal.SizeOf(typeof(struct1))); Console.WriteLine("sizeof array of bools: " + Marshal.SizeOf(typeof(struct2)));

C++/CLI Resource Management Confusion

别等时光非礼了梦想. 提交于 2019-11-29 17:18:31
问题 I am extremely confused about resource management in C++/CLI. I thought I had a handle (no pun intended) on it, but I stumbled across the auto_gcroot<T> class while looking through header files, which led to a google search, then the better part of day reading documentation, and now confusion. So I figured I'd turn to the community. My questions concern the difference between auto_handle/stack semantics, and auto_gcroot/gcroot. auto_handle: My understanding is that this will clean up a