interop

How to get pointer to IUnknown in C#

巧了我就是萌 提交于 2019-12-04 03:39:28
.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#? Hans Passant Use Marshal.GetIUnknownForObject() . 来源: https://stackoverflow.com/questions/3941349/how-to-get-pointer-to-iunknown-in-c-sharp

How to call managed C++ methods from Un-managed C++

倖福魔咒の 提交于 2019-12-04 03:30:38
问题 PLEASE SEE UPDATE BELOW (RESOLVED) Also I have extended this into a second question here Implement a C# DLL COM File In Unmanaged C++ Program I have researched this to the end of the internet without finding a real, understandable, human example of how to do this. I have a C# DLL that encrypts and decrypts text. I don't want to / don't have the intellectual capability to rewrite this in C++ un-managed code. So instead I created a C++/CLR class that interfaces with the C# dll. NOW I need to

Using Interop.MODI Throws 0x80040154 Exception

你。 提交于 2019-12-04 03:26:21
I am currently trying to implement the Interop.MODI.dll (From Microsoft Office) to use the Image -> Text features it should Provide. But when doing var modi = new MODI.DocumentClass(); I get: "COMException 80040154 with CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B}". What have I tried to solve that problem? I registered the DLL using the regasm tool: -Problem still exists I tried setting the BuildPlatform to x86: -Problem still exists I use the Visual Studio 2010 Ultimate with Windows 7 Professional 64Bit & Have Microsoft Office 2007 installed EDIT: I found the Solution: I needed to install the

Calling a Fortran function from Julia, returning an array: unknown function, segfault?

余生颓废 提交于 2019-12-04 03:21:35
问题 I want to call functions in my Fortran library from Julia. In this case, I have a function eye that takes an Integer, and returns a two-dimensional array of integers. The Fortran module is compiled into a shared library using $ gfortran -shared -fPIC -o matrix_routines.so matrix_routines.f90 And thereafter I am attempting to call it from the interactive Julia interpreter like that (name obtained from nm ): julia> n=5 5 julia> ccall( (:__matrix_routines_MOD_eye, "/path/to/library/matrix

Access Java fields dynamically in Clojure?

旧街凉风 提交于 2019-12-04 03:16:08
问题 I'm a novice in clojure and java. In order to access a Java field in Clojure you can do: Classname/staticField which is just the same as (. Classname staticField) (correct me if I'm wrong) How can I access a static field when the name of the field in held within a variable? i.e.: (let [key-stroke 'VK_L key-event KeyEvent/key-stroke]) I want key-stroke to be evaluated into the symbol VK_L before it tries to access the field. 回答1: In this case you might want to do something like the following:

Using Wrapper objects to Properly clean up excel interop objects

佐手、 提交于 2019-12-04 01:21:29
All of these questions: Excel 2007 Hangs When Closing via .NET How to properly clean up Excel interop objects in C# How to properly clean up interop objects in C# struggle with the problem that C# does not release the Excel COM objects properly after using them. There are mainly two directions of working around this issue: Kill the Excel process when Excel is not used anymore. Take care to explicitly assign each COM object used to a variable first and to guarantee that eventually, Marshal.ReleaseComObject is executed on each. Some have stated that 2 is too tedious and there is always some

P/Invoke with arrays of double - marshalling data between C# and C++

一笑奈何 提交于 2019-12-04 01:07:43
问题 I've read the various MSDN pages on C++ Interop with P/Invoke here and here but I am still confused. I have some large arrays of doubles that I need to get into native code, and some resulting arrays that need to get back. I do not know the sizes of the output arrays in advance. For simplicity, I will use only a single array in the example. The platform is x64; I read that marshalling internals are quite different between 32- and 64-bit environments so this might be important. C# [DllImport(

How can I deterministically dispose of a managed C++/CLI object from C#?

Deadly 提交于 2019-12-04 00:55:18
I have a managed object in a C++/CLI assembly. Being C++/CLI, it implements the Disposable pattern through its "destructor" (yes, I'm aware it's not the same as a standard C++ destructor). From C++/CLI, I would simply delete the object. However, I am using this object as a member variable in a C# class. From my C# class, then, I would like to call the equivalent of the Dispose() method on the C++/CLI object when I am finished using it. Since it is (and must be) a member variable of the class, utilizing a using() block is out of the question. As far as I can tell, there is no exposed method for

Cannot access excel file

最后都变了- 提交于 2019-12-04 00:20:49
问题 I'm developing a windows service, generating a report. This report has a template. This template is prepared in an excel file. This file is copied to the output folder. While developing I launched the service like a console application and had no problems accessing this file. Then I prepared a service installer. The service is installed under Local System account. So this excel template file is marked as content and copied to the installation directory together with the executable as well.

Windows Phone 8 (C++ Only) - Possible to access device manufacturer?

夙愿已清 提交于 2019-12-04 00:09:36
问题 Currently developing a Windows Phone 8 application in pure C++/Direct3D. We now need to access the Device Manufacturer name but it seems to only be available under C# which, according to my research is not accessible from this type of application. This page lists some of the calls I would like to use: http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.info.devicestatus(v=vs.105).aspx. // If only I could call this line from C++ DeviceStatus.DeviceManufacturer; Is