interop

C++/CLI delegate as function pointer (System.AccessViolationException)

五迷三道 提交于 2021-02-06 15:11:27
问题 I have been experimenting with C++/CLI delegates (as I am trying to make a .NET reference library), and I have been having the following problem. I define a delegate in C++/CLI, and then create an instance of the delegate in C#, and then call the instance of the delegate through unmanaged C++ via a function pointer. This all works as expected. Code to illustrate this (first my C#) using System; namespace TestProgram { class Program { static void Main(string[] args) { Library.Test

Interop with Microsoft Access does not interact with User's session

ε祈祈猫儿з 提交于 2021-02-04 21:16:18
问题 I am injecting a piece of VBA code into a Microsoft Access database from .Net. It is just a single line of code, which runs a Macro. All the Macro does is run a block of VBA code inside a module. The issue I am having is that this all happens in a new MSAccess session, which I can't even see, instead of the session the user currently has open. Is it possible to, instead, have this interact with the users current MSAccess session? The whole point of this is to open a particular form inside the

Call dotNET from Delphi and return a string

丶灬走出姿态 提交于 2021-02-04 11:30:24
问题 How does a Delphi application call an exported function (non-COM) dotNET assembly and have the function return a string? COM is not a possible solution for my particular application. I have control over both ends of the call. What I have tried so far - Delphi client side type TStrProc = procedure( var x: widestring); stdcall; function TryIt: string; var Handle: THandle; Proc: TStrProc; InData: widestring; OutData: widestring; begin Handle := LoadLibrary( 'DelphiToDotNet.dll'); if Handle = 0

Call dotNET from Delphi and return a string

Deadly 提交于 2021-02-04 11:30:06
问题 How does a Delphi application call an exported function (non-COM) dotNET assembly and have the function return a string? COM is not a possible solution for my particular application. I have control over both ends of the call. What I have tried so far - Delphi client side type TStrProc = procedure( var x: widestring); stdcall; function TryIt: string; var Handle: THandle; Proc: TStrProc; InData: widestring; OutData: widestring; begin Handle := LoadLibrary( 'DelphiToDotNet.dll'); if Handle = 0

VB.NET HID: SetupDiGetDeviceInterfaceDetail GetLastError() shows 1784 (ERROR_INVALID_USER_BUFFER) both times it is called

一笑奈何 提交于 2021-01-29 05:30:50
问题 I've been struggling with this for a while now, trying all sorts of things to get this to work. It's my understanding that SetupDiGetDeviceInterfaceDetail is supposed to give the 1784 error the first time around because the sole purpose of calling it the first time is to get RequiredSize set to the right value. The second time it's called, it's supposed to actually work and give me a valid DeviceInterfaceDetailData structure. I'm not sure what is causing this to fail on the second call.

How to to pass a C# delegate (callback) with a ref struct parameter to C++ using SWIG

烂漫一生 提交于 2021-01-29 05:15:21
问题 I am attempting to build C++ wrappers (using SWIG) for System.Text.Json.Utf8JsonWriter and System.Text.Json.Utf8JsonReader that allow C++ code to read and write JSON to the same reader/writer as client C# code. To do this I'm creating abstract classes in the C++ that match the interface of the Utf8JsonWriter and Utf8JsonReader class and then using SWIG director feature to enable me to create a derived class in C# that implements this interface and acts as a proxy calling the corresponding

How to insert image in a existing word document with c#

。_饼干妹妹 提交于 2021-01-28 14:22:45
问题 I am working with word and c# . taking the snap shot with my code and saving it in a particular folder (ex.C:\Temp). now i want to save the image to an existing word document.any kind of help with short code sample is highly appreciated . Will prefer to use Microsoft.Office.Interop.Word ; 回答1: Of course, the Word object model provides the required methods for inserting an image into the document. To add a picture at the cursor location you just need to call the AddPicture method of the

How do non-window program monitor system clipboard?

十年热恋 提交于 2021-01-27 16:02:09
问题 I want to write a program to monitor windows clipboard using C#. I found some post about this topic. According thread How to monitor clipboard content changes in C#? and Finding the handle to a WPF window, I write a demo using WPF. In all samples code I found, all of them are WinForm or WPF apps, and win32 api they interop with need window handle as parameters. Such as api function SetClipboardViewer(HWND hWndNewViewer) But in my scenario, I need my program run background as a service to

How do non-window program monitor system clipboard?

我的未来我决定 提交于 2021-01-27 15:56:49
问题 I want to write a program to monitor windows clipboard using C#. I found some post about this topic. According thread How to monitor clipboard content changes in C#? and Finding the handle to a WPF window, I write a demo using WPF. In all samples code I found, all of them are WinForm or WPF apps, and win32 api they interop with need window handle as parameters. Such as api function SetClipboardViewer(HWND hWndNewViewer) But in my scenario, I need my program run background as a service to

How do non-window program monitor system clipboard?

99封情书 提交于 2021-01-27 15:53:14
问题 I want to write a program to monitor windows clipboard using C#. I found some post about this topic. According thread How to monitor clipboard content changes in C#? and Finding the handle to a WPF window, I write a demo using WPF. In all samples code I found, all of them are WinForm or WPF apps, and win32 api they interop with need window handle as parameters. Such as api function SetClipboardViewer(HWND hWndNewViewer) But in my scenario, I need my program run background as a service to