interop

Unmanaged to managed callback much slower when target is in another AppDomain

时间秒杀一切 提交于 2019-12-08 16:56:50
问题 I'm calling managed code from unmanaged code using a delegate. When I call into managed code in the default AppDomain I'm measuring an average of 5.4ns per call. When I calling to a second AppDomain I'm measuring 194ns per call. (default VS2017 x86 release configuration, not running under the debugger). Why is performance so much lower when calling into an AppDomain that isn't the default? Since I'm coming from the unmanaged side, which has no knowledge of AppDomains I would expect to be

array<Byte>^ TO unsigned char* :: Marshall class - Interop Issue

こ雲淡風輕ζ 提交于 2019-12-08 14:23:31
I wanted to convert array< Byte>^ to unsigned char*. I have tried to explain what i have done. I donot know how to proceed further. Please show me the right approach. I am using MS VC 2005. //Managed array array<Byte>^ vPublicKey = vX509->GetPublicKey(); //Unmanaged array unsigned char vUnmanagedPublicKey[MAX_PUBLIC_KEY_SIZE]; ZeroMemory(vUnmanagedPublicKey,MAX_PUBLIC_KEY_SIZE); //MANAGED ARRAY to UNMANAGED ARRAY // Initialize unmanged memory to hold the array. vPublicKeySize = Marshal::SizeOf(vPublicKey[0]) * vPublicKey->Length; IntPtr vPnt = Marshal::AllocHGlobal(vPublicKeySize); // Copy the

What is the correct way to get OpenCL to play nice with OpenGL in Qt5?

喜欢而已 提交于 2019-12-08 13:02:24
问题 I have found several unofficial sources for how to get OpenCL to play nice with OpenGL and Qt5, each with different levels of complexity: https://github.com/smistad/Qt-OpenGL-OpenCL-Interoperability https://github.com/petoknm/QtOpenCLGLInterop http://www.krazer.com/?p=109 Having these examples is nice, however they don't answer the following question: What exact steps are the minimum required to have a Qt5 widgets program display the result of a calculation made in OpenCL kernel and then

Getting url and HTMl through a BHO, SetSite throws an exception

馋奶兔 提交于 2019-12-08 12:45:19
问题 I have followed the tutorial at: http://www.15seconds.com/issue/040331.htm for making a BHO, however i doesnt seem to work for me, i have the Observer code from the examble, where she creates the actual BHO, but when i try to typecast in my SetSite it stops, i suspect i get an exception. This is my sample code, just stripped it all bare, so i get a messagebox instead. [ClassInterfaceAttribute(ClassInterfaceType.None)] [GuidAttribute("0CD00297-9A19-4698-AEF1-682FBE9FE88D")] [ProgIdAttribute(

exporting selected cells from datagrigview to excel

梦想与她 提交于 2019-12-08 11:09:06
问题 Can anyone tell how to export the selected cells from a datagridview to excel ? The selection should be through a cell click event and the export it to the excel file when a button is clicked. Can anyone help me out.. 回答1: This should work: using Excel = Microsoft.Office.Interop.Excel; using System.Runtime.InteropServices; var rows = dataGridView1.Rows.Count; var columns = dataGridView1.Columns.Count; var dataAsObjectArray = new object[rows,columns]; for (int i = 0; i < rows; i++) { for (int

C# Interop.Outlook find messages with specific word in subject

两盒软妹~` 提交于 2019-12-08 09:13:09
问题 I have an application that needs to look for a given word in the subject of emails in the inbox. My code looks like this: outlook = new OL.Application(); outlookNameSpace = outlook.GetNamespace("mapi"); outlookNameSpace.Logon(Type.Missing, Type.Missing, false, true); inbox = outlookNameSpace.GetDefaultFolder(OL.OlDefaultFolders.olFolderInbox); inboxItems = inbox.Items; string filter = "@SQL =\"http://schemas.microsoft.com/mapi/proptag/0x0037001f\" LIKE 'Michigan'"; OL.Search advancedSearch =

How to use embedded registration-free manifest for ActiveX component from managed code like C#?

﹥>﹥吖頭↗ 提交于 2019-12-08 09:07:02
问题 I would like to use a specific version of ActiveX component that is not registered system- or user-wide. Everything works as expected if I use manifest files. However embedded manifest works only for C++ client code only. Here is dependency declaration <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="MapWinGIS.ocx" version="4.9.1.0" /> </dependentAssembly> </dependency> If I use SxStrace, I see the following INFO: Parsing Manifest File C:\OSGeo4W\bin\TestApplication.exe.

C# HwndSource from Process.MainWindowHandle

╄→尐↘猪︶ㄣ 提交于 2019-12-08 07:26:18
问题 I am trying to "hook" in to the messages of a window to detect a minimize/maximize. I've looked around, and think that the only/best solution to do this, is to hook into the messages of a window, and check for the WM_WINDOWPOSCHANGED message, and then check it's status. I've run into a problem. System.Windows.Interop.HwndSource source = System.Windows.Interop.HwndSource.FromHwnd(System.Diagnostics.Process.GetProcessesByName("notepad")[0].MainWindowHandle); System.Windows.Interop

Scala/Java interop: class type not converted?

陌路散爱 提交于 2019-12-08 07:09:15
问题 The javafx api is defined like this: void addListener(ChangeListener<? super java.lang.Boolean> listener) The following code.. new TextArea().focusedProperty.addListener(new ChangeListener[Boolean]() { def changed(observable: ObservableValue[_ <: Boolean], oldValue: Boolean, newValue: Boolean) { } }) ..gives this error: overloaded method value addListener with alternatives: (javafx.beans.value.ChangeListener[_ >: java.lang.Boolean])Unit (javafx.beans.InvalidationListener)Unit cannot be

How do I define the TBBUTTON struct in C#?

旧时模样 提交于 2019-12-08 06:32:25
Greetings all, The TBBUTTON struct is defined on MSDN as follows: typedef struct { int iBitmap; int idCommand; BYTE fsState; BYTE fsStyle; #ifdef _WIN64 BYTE bReserved[6]; #else #if defined(_WIN32) BYTE bReserved[2]; #endif #endif DWORD_PTR dwData; INT_PTR iString; } TBBUTTON, *PTBBUTTON, *LPTBBUTTON; I need to do some interop in C# using this struct. How do I replicate this monster so that it's defined correctly when compiled for AnyCPU? Google is apparently full of dangerous misinformation! Ahah, I knew there had to be a way. And here it is: [StructLayout(LayoutKind.Sequential)] public