interop

IntPtr to Byte Array and Back

一世执手 提交于 2019-12-17 19:24:08
问题 Referencing How to get IntPtr from byte[] in C# I am attempting to read the data that an IntPtr is referencing into a byte [] and then back into another IntPtr. The pointer is referencing an image captured from a scanner device so I have also made the assumption that capturing this information should be placed into a byte array. I am also not sure if the Marshal.SizeOf() method will return the size of the data the IntPtr is referencing or the size of the pointer itself. My issue is I am

P/Invoke tutorials?

一笑奈何 提交于 2019-12-17 18:43:56
问题 Does anyone know of a good tutorial/e-book that goes in depth on the System.Runtime.InteropServices namespace? I just got through reading this tutorial on how to make the UAC shield show up in a button and now I really want to learn this. P.S. How do look in the windows system files to know that a method exist to show a UAC shield in a button? 回答1: As for your p.s., the code you need is in the information you provided. You use the SendMessage method to send the BCM_SETSHIELD message to a

Java and MSMQ

青春壹個敷衍的年華 提交于 2019-12-17 16:37:07
问题 I was curious if anyone had any suggestions on a Java library that provides access to MSMQ? I've downloaded the trial of the J-Integra Java-COM library and have built and run their MSMQ example app, but I was curious if there were any good (free :)) alternatives. I've run across a few JNI implementations like jMSMQ and a few others, but I'd rather avoid JNI if possible. We've also investigated some .NET<->JMS interop solutions like JNBridge (with ActiveMQ). I think our company has decided to

Call C# dll function from C++/CLI

ε祈祈猫儿з 提交于 2019-12-17 16:34:13
问题 I have a C# dll. The code is below: public class Calculate { public static int GetResult(int arg1, int arg2) { return arg1 + arg2; } public static string GetResult(string arg1, string arg2) { return arg1 + " " + arg2; } public static float GetResult(float arg1, float arg2) { return arg1 + arg2; } public Calculate() { } } Now, I am planning to call this dll from C++ on this way. [DllImport("CalculationC.dll",EntryPoint="Calculate", CallingConvention=CallingConvention::ThisCall)] extern void

Using SetWindowPos in C# to move windows around

允我心安 提交于 2019-12-17 15:48:10
问题 I have the code below: namespace WindowMover { using System.Windows.Forms; static class Logic { [DllImport("user32.dll", EntryPoint = "SetWindowPos")] public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags); public static void Move() { const short SWP_NOMOVE = 0X2; const short SWP_NOSIZE = 1; const short SWP_NOZORDER = 0X4; const int SWP_SHOWWINDOW = 0x0040; Process[] processes = Process.GetProcesses("."); foreach (var process in

Convert Kotlin Array to Java varargs

天涯浪子 提交于 2019-12-17 15:43:05
问题 How can I convert my Kotlin Array to a varargs Java String[] ? val angularRoutings = arrayOf<String>("/language", "/home") // this doesn't work web.ignoring().antMatchers(angularRoutings) How to pass an ArrayList to a varargs method parameter? 回答1: You should use the " spread operator ", which looks like this: * The spread operator needs to be prefixed to the array argument: antMatchers(*angularRoutings) For further information, see the documentation: When we call a vararg -function, we can

Convert Kotlin Array to Java varargs

老子叫甜甜 提交于 2019-12-17 15:41:57
问题 How can I convert my Kotlin Array to a varargs Java String[] ? val angularRoutings = arrayOf<String>("/language", "/home") // this doesn't work web.ignoring().antMatchers(angularRoutings) How to pass an ArrayList to a varargs method parameter? 回答1: You should use the " spread operator ", which looks like this: * The spread operator needs to be prefixed to the array argument: antMatchers(*angularRoutings) For further information, see the documentation: When we call a vararg -function, we can

calling managed code from unmanaged code

时光怂恿深爱的人放手 提交于 2019-12-17 09:43:54
问题 I want to call my .NET code from unmanaged C++. My process entrypoint is .NET based, so I don't have to worry about hosting the CLR. I know it can be done using COM wrappers for .NET objects, but I would like to access individual static methods of managed classes, so COM isn't my shortest/easiest route. Thanks! 回答1: Assuming you are talking about real unmanaged code - not just native C++ running in a mixed-mode assembly compiled with /clr - the easiest way is to create a wrapper to your .NET

How to make a Swift String enum available in Objective-C?

我只是一个虾纸丫 提交于 2019-12-17 09:43:09
问题 I have this enum with String values, which will be used to tell an API method that logs to a server what kind of serverity a message has. I'm using Swift 1.2, so enums can be mapped to Objective-C @objc enum LogSeverity : String { case Debug = "DEBUG" case Info = "INFO" case Warn = "WARN" case Error = "ERROR" } I get the error @objc enum raw type String is not an integer type I haven't managed to find anywhere which says that only integers can be translated to Objective-C from Swift. Is this

How do I import from Excel to a DataSet using Microsoft.Office.Interop.Excel?

北慕城南 提交于 2019-12-17 06:26:33
问题 What I want to do I'm trying to use the Microsoft.Office.Interop.Excel namespace to open an Excel file (XSL or CSV, but sadly not XSLX) and import it into a DataSet. I don't have control over the worksheet or column names, so I need to allow for changes to them. What I've tried I've tried the OLEDB method of this in the past, and had a lot of problems with it (buggy, slow, and required prior knowledge of the Excel file's schema), so I want to avoid doing that again. What I'd like to do is use