pinvoke

Implement lens magnification to magnify the Windows Taskbar

谁说我不能喝 提交于 2021-02-11 15:19:13
问题 I want to be able to perform lens magnificaiton on top of the windows taskbar. So far I've been unsuccessful in implementing this seeing as the taskbar will always open on top of my window. Windows built-in magnifier is able to do this so I'm hoping it is indeed possible. I've attached two screenshots showing Windows built-in magnifier and how it is able to magnify the taskbar and how my application will render below the taskbar. Windows built-in Magnifier: My application: Is there any way to

How to fix System.TypeLoadException when declaring structs with union?

浪尽此生 提交于 2021-02-11 14:17:16
问题 Receiving System.TypeLoadException in runtime. I use code from third-party source to define structs and p-invoke external methods. I found the full code online in this link. In the code there are some structs with union, using FieldOffsetAttribute(0) on multiple fields. when I try to use some of the structs I get an exception: Could not load type 'NET_DVR_SLAVE_CHANNEL_UNION' from assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because it contains an object

How to P/Invoke “__arglist” function?

别说谁变了你拦得住时间么 提交于 2021-02-10 15:11:30
问题 Background: I have written the following function in C++: extern "C" __declspec(dllexport) int test(const char*, ...); And I am using P/Invoke to call it from C#: [DllImport("foo/bar.dll", EntryPoint = "test")] public static unsafe extern int __unmanaged__test(byte* buffer, __arglist); Problem: I need to initialize the __arglist dynamically, meaning that I have an Array<object> , which I have to convert into the __arglist before calling the C++-function. I have tried the following, but it

How to map a C array to C#?

谁都会走 提交于 2021-02-10 02:32:18
问题 My question has to do with trying to call a function written in C from C#. I've looked in a header file that came with the C library to understand the functions as they exist in the C dll. Here's what I see: C code (for a function called "LocGetLocations"): typedef enum { eLocNoError, eLocInvalidCriteria, eLocNoMatch, eLocNoMoreLocations, eLocConnectionError, eLocContextError, eLocMemoryError } tLocGetStatus; typedef void *tLocFindCtx; typedef void *tLocation; PREFIX unsigned int POSTFIX

Callback from Unmanaged code to managed

痞子三分冷 提交于 2021-02-09 02:54:36
问题 I am triggering my managed code and initiating a call to unmanaged code. There is a callback in unmanaged code. From unmanaged I am getting callback in my managed method 'DelegateMethod'. But I am not getting proper parameter/argument values from unmanaged code. Please help me with this using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace TestApp { public class Program { public delegate void fPointer(byte[]

Callback from Unmanaged code to managed

雨燕双飞 提交于 2021-02-09 02:53:47
问题 I am triggering my managed code and initiating a call to unmanaged code. There is a callback in unmanaged code. From unmanaged I am getting callback in my managed method 'DelegateMethod'. But I am not getting proper parameter/argument values from unmanaged code. Please help me with this using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace TestApp { public class Program { public delegate void fPointer(byte[]

Pinvoking functions from a static C library

孤人 提交于 2021-02-07 20:53:00
问题 I have a native C++ library (static i.e. .lib target). I wish to use some of the functions in this file in my C# projects. For dlls, I could pinvoke them. How do I do this for static libraries? I read this question and there David's answer says you can pinvoke only for dlls and not for libs. 回答1: A static library is used by linking it into a larger module. In Windows that means a DLL or an executable. They do not stand alone and only make sense when you link them into a larger module. So,

Restore suppressed cursor after touch injection

两盒软妹~` 提交于 2021-02-07 12:56:24
问题 I'm writing a helper for injecting touch in UI-tests using InjectTouchInput. The injected touch works fine but injecting mouse input after touch does not work. Mouse.Click(point); // works Touch.Tap(point); // works Mouse.Click(point); // does not work, mouse cursor no longer visible on screen. Calling GetCursorInfo() reveals that cursor is CURSOR_SUPPRESSED and I have not found a way to restore it. Moving the physical mouse brings back the cursor and clicking things work fine. How can I

Restore suppressed cursor after touch injection

别来无恙 提交于 2021-02-07 12:56:11
问题 I'm writing a helper for injecting touch in UI-tests using InjectTouchInput. The injected touch works fine but injecting mouse input after touch does not work. Mouse.Click(point); // works Touch.Tap(point); // works Mouse.Click(point); // does not work, mouse cursor no longer visible on screen. Calling GetCursorInfo() reveals that cursor is CURSOR_SUPPRESSED and I have not found a way to restore it. Moving the physical mouse brings back the cursor and clicking things work fine. How can I

Receiving Input From RawInput Registered Devices In c#

放肆的年华 提交于 2021-02-07 10:50:30
问题 So I have a console application and I've imported RegisterRawInputDevices from user32.dll You can't register a device onto the console window handler, so I've created a class that inherits from Form. This is also the class that overrides WndProc. Right now all I'm having it do is write message.Msg to the console. So I instantiate the form and pass the window handler to RegisterRawInputDevices where it registers the mouse and keyboard. But after that the window no longer receives any messages.