unmanaged

Passing pointer to pointer of array of structure from C# to C++

五迷三道 提交于 2021-02-17 00:01:12
问题 I want to pass pointer to pointer of an array of structure from C# to C++. With following code I only get the first element in c++, second and third element of the array is not passed. Why? Also, tried using StructureToPtr but didn't help. What I am doing wrong? C++ code struct structure { short ps; }; __declspec(dllexport)short Testmethod(structure** aa) { if (aa!= 0 && aa[0]->ps == 26 && aa[1]->ps == 27) { return 1; } return 0; } C# code [DllImport("Wrapper.dll", CallingConvention =

Passing pointer to pointer of array of structure from C# to C++

ε祈祈猫儿з 提交于 2021-02-17 00:00:16
问题 I want to pass pointer to pointer of an array of structure from C# to C++. With following code I only get the first element in c++, second and third element of the array is not passed. Why? Also, tried using StructureToPtr but didn't help. What I am doing wrong? C++ code struct structure { short ps; }; __declspec(dllexport)short Testmethod(structure** aa) { if (aa!= 0 && aa[0]->ps == 26 && aa[1]->ps == 27) { return 1; } return 0; } C# code [DllImport("Wrapper.dll", CallingConvention =

C# marshal unmanaged pointer return type

馋奶兔 提交于 2021-02-07 11:59:52
问题 I have an unmanaged library which has a function like this: type* foo(); foo basically allocates an instance of the unmanaged type on the managed heap through Marshal.AllocHGlobal . I have a managed version of type . It's not blittable but I have MarshalAs attributes set on members so I can use Marshal.PtrToStructure to get a managed version of it. But having to wrap calls to foo with extra bookkeeping to call Marshal.PtrToStructure is a bit annoying. I'd like to be able to do something like

SetWindowsHookEx hook stops working

冷暖自知 提交于 2021-02-07 04:32:26
问题 Keyboard hook not firing events and throws win32 exception on dispose My c# application creates keyboard hook for processing of keyboard events(many card readers, scanners and other POS equipment emulates keyboard). Sometimes my application creates keyboard hook without errors, but it's not firings events and on dispose throws exception: System.ComponentModel.Win32Exception (0x80004005): Failed to remove keyboard hooks for 'app'. Error 1404: Invalid hook handle Other log entry is same error,

Why are C# callbacks only executed when the python module uses cv.imshow()?

一笑奈何 提交于 2020-04-16 05:48:52
问题 I couldn't come up with a better more descriptive title as it involves 3 languages which I'll explain now. I wrote a C++ wrapper around a Python module, which works just fine in C++ by the way. I made a DLL out of this wrapper and exposed some functionalities as a C and used them in a C# application. The issue is, the C# application just hangs if I do not display the webcam feed. That is in Python module there is this condition: if self.debug_show_feed: cv2.imshow('service core face Capture',

How to get the name of a Win32 Thread?

若如初见. 提交于 2020-01-29 04:32:54
问题 I know of the non-intuitive process to set the name of a thread under Windows (see "How to set name to a Win32 Thread?"). Is there a way to get the name of the thread? I don't see any Windows API that lets me do this (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684847(v=vs.85).aspx). 回答1: There is no such WinAPI call since there exists no such thing as thread names. If you set a thread name then the debugger of your IDE will store it for you, which makes it easier to debug.

How to get the name of a Win32 Thread?

这一生的挚爱 提交于 2020-01-29 04:32:45
问题 I know of the non-intuitive process to set the name of a thread under Windows (see "How to set name to a Win32 Thread?"). Is there a way to get the name of the thread? I don't see any Windows API that lets me do this (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684847(v=vs.85).aspx). 回答1: There is no such WinAPI call since there exists no such thing as thread names. If you set a thread name then the debugger of your IDE will store it for you, which makes it easier to debug.

Return unsafe pointer to type parameter

放肆的年华 提交于 2020-01-29 03:45:07
问题 I am trying to define a property that returns a pointer to a generic type argument like so: public class MemWrapper<T> where T: struct { readonly IntPtr pointerToUnmanagedHeapMem; // ... do some memory management also ... public unsafe T* Ptr { get {return (T*)(pointerToUnmanagedHeapMem);} } } The compiler complains that it is not possible to declare a pointer to the managed type T or get its address or size (CS0208). The curious thing is, if I manually replace the generic type parameter by a

Access Violation with unmanaged DLL

牧云@^-^@ 提交于 2020-01-25 04:48:04
问题 Currently, we use an unmanaged DLL from a vendor that allows us to access a particular instrument. The particular function of interest is specified in a header file as this: extern "C" short CCONV acq_get_board_count (); In my application, I have the pinvoke statement: public class bograms { [DllImport("bograms.dll", EntryPoint = "acq_get_board_count", CallingConvention = CallingConvention.StdCall)] public static extern short acq_get_board_count(); } Now, in my code I am attempting to handle