interop

Receive WM_COPYDATA struct in WPF or Console C# app

天涯浪子 提交于 2019-12-22 04:48:18
问题 I am writing a C# application that needs to communicate with another application written in native C. So far I have figured out how to send messages from my C# app to the C app with the User32.dll SendMessage. However I am unable to figure out how to get the C# app to RECEIVE messages from the C app. I have seen WinForms examples of overriding the WndProc method, but there is no WndProc method to override in a WPF or Console application. Surely it's possible to do in a Console application at

Can't access variable in C++ DLL from a C app

一曲冷凌霜 提交于 2019-12-22 04:38:16
问题 I'm stuck on a fix to a legacy Visual C++ 6 app. In the C++ DLL source I have put extern "C" _declspec(dllexport) char* MyNewVariable = 0; which results in MyNewVariable showing up (nicely undecorated) in the export table (as shown by dumpbin /exports blah.dll). However, I can't figure out how to declare the variable so that I can access it in a C source file. I have tried various things, including _declspec(dllimport) char* MyNewVariable; but that just gives me a linker error: unresolved

Is it possible to host a Microsoft Access form inside a .Net Windows form?

眉间皱痕 提交于 2019-12-22 03:55:30
问题 I am asking if it is possible to host a Microsoft Access form inside a .Net form. No I haven't gone mad, we are maintaining a massive system written entirely in VBA by somebody who didn't know a lot of VBA attempting to use Microsoft Access as an IDE. It's basically thousands of lines of spaghetti code and while we would love to scrap it and start from scratch, this is not an option. We are therefore trying to improve what is there, and in this particular scenario it would be really helpful

Why do WinRT types have to be sealed?

自古美人都是妖i 提交于 2019-12-22 03:43:58
问题 In several places (e.g. "Creating Windows Runtime Components for JavaScript, in C# and Visual Basic" on MSDN), I've seen it specified that, if you write a class in .NET that you want to use from JavaScript, then you must make it a sealed class. This seems like an arbitrary restriction. Why can JavaScript only work with sealed classes? 回答1: Windows runtime objects exposed to JavaScript applications are sealed from a JavaScript perspective - you can't add expando properties to WinRT objects.

Use a .OCX Control in Java

人走茶凉 提交于 2019-12-22 00:46:39
问题 IS there a way to use a ocx control ( VB6) from Java? 回答1: Here are some links of Java/COM bridges. http://sourceforge.net/projects/jacob-project/ http://javacombridge.com/ http://sourceforge.net/projects/j-interop/ http://java2com.com/ http://j-integra.intrinsyc.com/ The last one has a lot of samples using their bridge, you might be able to either use their product or get ideas on how to do the Java part if you are going to roll your own. You can also wrap your own using JNI. 回答2: The only

Is there a best practice for accessing C++ native COM functions to interop from C#?

怎甘沉沦 提交于 2019-12-22 00:36:21
问题 Is there a best practice for accessing C++ native COM functions to interop from C#? For example, if I have 100 C++ methods (basically a native library) that interacts with a core window component. I want to basically make a wrapper for these C++ methods in C#, so all my newly hired employees can use that instead of C++, etc. The C++ code is legacy and scares me, so I want to deal with it just once. Is the approach here for each method to have a corresponding C# method? In fact, is there

From VB6 to .net via COM and Remoting…What a mess!

穿精又带淫゛_ 提交于 2019-12-22 00:26:43
问题 I have some legacy vb6 applications that need to talk to my .Net engine application. The engine provides an interface that can be connected to via .net Remoting. Now I have a stub class library that wraps all of the types that the interface exposes. The purpose of this stub is to translate my .net types into COM-friendly types. When I run this class library as a console application, it is able to connect to the engine, call various methods, and successfully return the wrapped types. The next

WPF HwndHost keyboard focus

有些话、适合烂在心里 提交于 2019-12-21 21:58:08
问题 The chart area in the screenshot is a HwndHost control which hosts a native Win32 window (with it's own registered WNDCLASS) implemented in C++/CLI and drawn with Direct2D. The HwndHost is hosted in a WPF Border control. The problem I have is that I can't set the keyboard focus to the hosted Win32 window. I want the focus to move to the hosted Win32 window when the used clicks on the chart area. I tried calling SetFocus on WM_LBUTTONDOWN, but that screws up the focus in the rest of the

C# How do you get an instance of a COM interface

人盡茶涼 提交于 2019-12-21 21:54:33
问题 I've been doing quite a bit of googling trying to find the standard way to get an instance of a COM interface. Microsoft provides an example of this in their article COM Interop Part 1: Client Tutorial: // Create an instance of a COM coclass: FilgraphManager graphManager = new FilgraphManager(); // See if it supports the IMediaControl COM interface. // Note that this will throw a System.InvalidCastException if // the cast fails. This is equivalent to QueryInterface for // COM objects:

Wrapping Visual C++ in C#

感情迁移 提交于 2019-12-21 21:27:55
问题 I need to do some process injection using C++ but I would prefer to use C# for everything other than the low level stuff. I have heard about "function wrapping" and "marshaling" and have done quite a bit of google searching and have found bits of information here and there but I am still really lacking. Things I have read in order of usefulness; http://msdn.microsoft.com/en-us/library/ms235281(VS.80).aspx http://www.drdobbs.com/cpp/184401742 http://geeklit.blogspot.com/2006/08/calling-c-lib