interop

Clojure: working with a java.util.HashMap in an idiomatic Clojure fashion

强颜欢笑 提交于 2019-11-27 12:51:19
问题 I have a java.util.HashMap object m (a return value from a call to Java code) and I'd like to get a new map with an additional key-value pair. If m were a Clojure map, I could use: (assoc m "key" "value") But trying that on a HashMap gives: java.lang.ClassCastException: java.util.HashMap cannot be cast to clojure.lang.Associative No luck with seq either: (assoc (seq m) "key" "value") java.lang.ClassCastException: clojure.lang.IteratorSeq cannot be cast to clojure.lang.Associative The only way

Printing Excel using Interop

☆樱花仙子☆ 提交于 2019-11-27 12:28:31
Does anybody have any idea how to print an excel file programatically using C# and the Excel Interop? If so, can you please provide code? In order to print, you can make use of the Worksheet.PrintOut() method. You can omit any or all of the optional arguments by passing in Type.Missing . If you omit all of them, it will default to printing out one copy from your active printer. But you can make use of the arguments to set the number of copies to print, collation, etc. See help on the Worksheet.PrintOut() method for more. The example they show in the help file is: private void PrintToFile() { /

Send message to a Windows process (not its main window)

旧巷老猫 提交于 2019-11-27 11:51:25
I have an application that on a subsequent start detects if there's a process with the same name already running and, if so, activates the running app's window and then exits. The problem is that the main window could be hidden (only a notification area icon visible), thus leaving me with no window handle. At startup, previous instance's MainWindowHandle property is 0, so I can't send ShowWindow or PostMessage . Is there any way I can send a message that can be intercepted by the running app, thus allowing it to display its main window? The application is written in C#, the code I'm using to

Writing a DLL in C/C++ for .Net interoperability

a 夏天 提交于 2019-11-27 11:37:05
In my C# application, I would like to write a part of the code in C. I plan to write a DLL witch would be interoperable with .Net. How can I do that? There are essentially three right ways to do it: Use C++/CLI. This is the optimal way if this DLL is going to be used only by .NET. Use an " extern "C" " compatible API, like the Windows API itself. This is the most portable, but isn't as convenient for your callers as using a class model to represent your objects. This is the best option if you really intend to write in ANSI C (not C++). For this path, you write your functions as extern "C"

Accessing unregistered COM objects from python via a registered TLB

筅森魡賤 提交于 2019-11-27 11:21:03
问题 I have three pieces of code that i'm working with at the moment: A closed source application (Main.exe) A closed source VB COM object implemented as a dll (comobj.dll) Code that I am developing in Python comobj.dll hosts a COM object (lets say, 'MainInteract') that I would like to use from Python. I can already use this object perfectly fine from IronPython, but due to other requirements I need to use it from regular Python. I believe the best method here is to use win32com, but I can't quite

COM object that has been separated from its underlying RCW cannot be used

谁说胖子不能爱 提交于 2019-11-27 10:56:06
I am trying to use the OpcRcw.da.dll. If I interop this dll inside a test console project everything works, but if I build dll project to do my interop gymnastic and ref my library into my console project I am getting this error: COM object that has been separated from its underlying RCW cannot be used. What need to be done to a class lib project to not kill the RCW ref? It's somewhat hard to tell what your actual application is doing, but it sounds like you may be instantiating the COM object and then attempting to access it from another thread, perhaps in a Timer.Elapsed event. If your

What is the interop dll?

こ雲淡風輕ζ 提交于 2019-11-27 10:41:48
问题 I need some clarification. I have a Reportwriter dll that uses Crystal Reports. It is written in VB6. I have to add this dll to my asp.net project, where it creates an interop dll. To my understanding, the interop dll is there as an intermediary so that my .net code can speak to the Reportwriter dll. So do I register the interop dll or do I register the original dll? 回答1: When you write code in VB6, the compiled result is a COM component. COM components provide interfaces, coclasses, structs

How to get type of COM object

亡梦爱人 提交于 2019-11-27 10:32:54
问题 I am referencing a COM library in Visual Studio, so it has automatically created the corresponding Interop assembly for me. I would like to do a GetType() on these com objects, but they always return System.__ComObject . Querying them for an interface works though: bool isOfType = someComeObject is ISomeComObject; //this works But what I really want is this to return the actual type of the com object: Type type = someComeObject.GetType(); //returns System.__ComObject :-( Does anyone know how

Handling Null Values in F#

假装没事ソ 提交于 2019-11-27 10:19:41
问题 I need to interop with some C# code with F#. Null is a possible value that it is given so I need to check if the value was null. The docs suggest using pattern matching as such: match value with | null -> ... | _ -> ... The problem I'm having is the original code is structured in C# as: if ( value != null ) { ... } How do I do the equivalent in F#? Is there a no-op for pattern matching? Is there a way to check for null with an if statement? 回答1: If you don't want to do anything in the null

Windows Forms window changes its size when I create a WPF window

僤鯓⒐⒋嵵緔 提交于 2019-11-27 09:43:42
I have a System.Window.Forms.Form where I handle every button click. When I receive the first event I create a new WPF System.Windows.Window object. class WPF_Window : Window { } public partial class Form1 : Form { WPF_Window wnd = null; public Form1() { InitializeComponent(); } private void Form1_MouseClick(object sender, MouseEventArgs e) { if (wnd == null) { wnd = new WPF_Window(); } } } On my computer this code works as expected, but if I run it on another computer (both Windows 10) when I click the Windows Forms window changes its size (decreasing its dimensions). How is it possible? How