interop

How from Ocaml can I call C++ code using itself a shared library .so ?

北战南征 提交于 2019-12-10 14:44:38
问题 I need to build an Ocaml/C++ module which calls a shared object (.so under linux) As long as it is a question to compile a simple Ocaml/C++ stub, I manage the thing but when I need to link the .so with ocamlmklib or ocamlopt, it fails I work under gcc 4.5 (c++0x) files for the shared object : hello.hpp #include <iostream> #include <string> using namespace std; class HelloApplication { public : HelloApplication(); ~HelloApplication(); void say(string s); }; typedef HelloApplication *(*create

C# Interop - Releasing memory allocated in unmanaged code

穿精又带淫゛_ 提交于 2019-12-10 13:55:32
问题 I'm calling the following VC++ method __declspec(dllexport) unsigned char* Get_Version_String() from C# as follows: internal static class NativeMethods { [DllImport("my.dll"), CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true, CallingConvention = CallingConvention.Cdecl)] internal static extern string Get_Version_String(); } The above code is in a library which targets .NET 3.5. When I call this from a 3.5 assembly, it works fine; when calling it from a 4.5 assembly

How can I make word visible when opening a document through interop?

强颜欢笑 提交于 2019-12-10 13:36:17
问题 I want to open a word document through interop and word must be visible in the process.It looks to be fairly straight forward because there is a parameter called "visible in the open function on a word document. But word is in the background. What am I missing? static void Main(string[] args) { Microsoft.Office.Interop.Word.Application word = null; word = new Microsoft.Office.Interop.Word.Application(); object inputFile = "c:\\test.docx"; object confirmConversions = false; object readOnly =

Pinning an empty array

℡╲_俬逩灬. 提交于 2019-12-10 13:14:08
问题 In C++/CLI, is it possible to pin an array that contains no elements? e.g. array<System::Byte>^ bytes = gcnew array<System::Byte>(0); pin_ptr<System::Byte> pin = &bytes[0]; //<-- IndexOutOfRangeException occurs here The advice given by MSDN does not cover the case of empty arrays. http://msdn.microsoft.com/en-us/library/18132394%28v=VS.100%29.aspx As an aside, you may wonder why I would want to pin an empty array. The short answer is that I want to treat empty and non-empty arrays the same

Explanation of SendMessage message numbers?

£可爱£侵袭症+ 提交于 2019-12-10 12:42:49
问题 I've successfully used the Windows SendMessage method to help me do various things in my text editor, but each time I am just copying and pasting code suggested by others, and I don't really know what it means. There is always a cryptic message number that is a parameter. How do I know what these code numbers mean so that I can actually understand what is happening and (hopefully) be a little more self-sufficient in the future? Thanks. Recent example: using System.Runtime.InteropServices;

OpenGL + CUDA interop - image not displaying in window

随声附和 提交于 2019-12-10 12:21:56
问题 Background : I read an image from disk using OpenCV, passed it to the GPU using CUDA, and now, I am trying to get OpenGL to render the image. I am not using GLUT here because I compile my code and get 32-bit Windows to create a new window, inside which I will render the image. Now, I flipped the OpenCV image and got OpenGL to render the image nicely when I simply passed flipped.data to the glTexImage2D() function. However, the same image is not being rendered when I use CUDA + OpenGL. My

Does a C# method need to be pinned when used as Win32 callback?

China☆狼群 提交于 2019-12-10 12:18:37
问题 I am passing a C# instance method to a Win32 API call that will later be used as a callback function from Windows into my application. When I pass a reference to an object, that reference is temporarily pinned until the call returns (see this article by Jason Clark). If the API call will retain the address for later use after the call returns, I have to pin the object explicitly before the call (I can allocate it from unmanaged memory via Marshal.AllocHGlobal, or I can pin down a managed

Delay when creating Microsoft.Office.Interop.Word.Application

孤人 提交于 2019-12-10 12:16:04
问题 I've got an (legacy VB.Net) application that pulls data from some tables, populates a word template, and concatenates that template with several other files. On several machines this works with no issues, but for one client there is a persistent problem where the Word Interop code throws Object reference not set to an instance of an object when attempting to open the template file (which exists, and has no permission issues, etc). Dim doc As Document Dim msWord As Microsoft.Office.Interop

Changing the string to which an IntPtr is pointing

≡放荡痞女 提交于 2019-12-10 12:15:57
问题 In my C# application I have a variable lpData of type IntPtr (received from a call to unmanaged code), and it points to a string. I have to replace this string with another value. I tried: int RegQueryValueExW_Hooked( IntPtr hKey, string lpValueName, int lpReserved, ref Microsoft.Win32.RegistryValueKind lpType, IntPtr lpData, ref int lpcbData) { lpData = Marshal.StringToHGlobalUni("new string"); ... } but this doesn't seem to replace the actual string. Can someone point me in the right

How to force process isolation for an out of process COM server?

二次信任 提交于 2019-12-10 11:49:57
问题 I'm writing managed code that has to interact with a vendor's COM automation server that runs out of process. I have found that this server becomes unstable if more than one client connects to it. For example, if I have managed code in process A and managed code in process B both connecting to this COM server, a single process will be spun up for the COM server and it's behavior is less than reliable. I'm hoping there's a way to force a separate process for each client - server connection .