Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [pinvoke]

P/Invoke is an implementation specification created by Microsoft of the Common Language Infrastructure (CLI) for invocation of native code libraries from managed code.

0 votes
0 answers
16 views

Getting correct SignerInfos of a file via Powershell?

I am working on a Powershell-Sample to read all certificates and SignerInfos from a file. Below the code I have so far. It gives me all certs but only the first signer and this is in my case "the ...
Carsten's user avatar
  • 1,979
0 votes
0 answers
46 views

Low level mouse hook handles mouse scroll in Windows, but not Fallout 4 [duplicate]

The idea is to caputre the mouse scroll and then return handled, entirely disabling it. The issue is that it doesn't work in-game for some reason. Pseudo-code to explain how my code works: var handle =...
Eduard G's user avatar
  • 473
3 votes
1 answer
85 views

How do I marshal a C# struct with delegate fields?

I'm writing a C# wrapper for SDL3. I'm currently trying to implement the following struct: typedef struct SDL_VirtualJoystickDesc { Uint16 type; /**< `SDL_JoystickType` */ Uint16 ...
lumPalette's user avatar
0 votes
0 answers
125 views

Interop Delphi dll / C# - bad memory allocation or marshaling

I'm making a wrapper to call a Delphi dll in a C# app, and I'm struggling to make it work. It doesn't crash but the returned result is random data from memory. I don'tknow if the problem is coming ...
ADM's user avatar
  • 1
2 votes
1 answer
52 views

Why would I need `DangerousAddRef`/`DangerousRelease` around `DangerousGetHandle`?

I've been looking into the Microsoft.Windows.CsWin32 NuGet package and comparing the P/Invoke code it generates to what I would write by hand. In some cases it uses SafeHandle.DangerousAddRef/...
Matt Tsōnto's user avatar
  • 1,672
0 votes
0 answers
49 views

PInvoke memory management: strings inside structs passed by reference

I have a question about the releasing of memory when marshalling structs containing strings across pInvoke I want to return a result struct by reference, since the calling code can not directly return ...
Hottemax's user avatar
  • 344
1 vote
0 answers
37 views

Move top menu from a hosted program to the main wpf app

I'm making a wpf app (,net framework) which hosts an external app (mfc program), to host it I'm using a WindowsFormsHost control and the SeParent function from pInvoke like that: int style = ...
Enric's user avatar
  • 55
-2 votes
1 answer
133 views

DllImport not executing functions in library but no error codes [closed]

I am developing on Windows 11 and have been given an unmanaged C dll. However I am running into the issue that I am unable to execute the functions in the library. I do not get any errors, the ...
Iridium's user avatar
  • 137
4 votes
1 answer
223 views

Distribute DLLs in Nuget

I am working on a C# library (LLamaSharp) which wraps a C++ library (llama.cpp). As part of the nuget package we're including DLLs compiled with all the various types of hardware support (CUDA, OpenCL,...
Martin's user avatar
  • 12.4k
-1 votes
1 answer
85 views

How to marshal a struct with a nested array of structs when using P/Invoke C#

I have the following C function declaration which I would like to call from C# (Note I cannot access the source code of the dll): int setData(OuterStruct *data); And the relevant structs for this C ...
Z A's user avatar
  • 1
2 votes
1 answer
232 views

CsWin32 how to create an instance of PWSTR for e.g. GetWindowText

I just started using CsWin32 and one of the Win32 functions I want to use it GetWindowText which gets mapped to I know how to work with the first and last parameter, but I don't know what to do with ...
me.at.coding's user avatar
  • 16.7k
0 votes
1 answer
79 views

.NET app call unmanged DLL, parameters contains strange characters

I am wring a .NET app to call an unmanaged DLL(Unicode). Below is the header for the unmanaged DLL: #pragma once #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ // Callback ...
alancc's user avatar
  • 581
0 votes
0 answers
13 views

Working with errno in a cross-platform way in .NET

I am writing a cross-platform .NET library which relies on P/Invoke into system libraries. I need to handle errors which invoked functions report through the errno variable. This variable can be ...
Dark Daskin's user avatar
  • 1,438
-1 votes
1 answer
40 views

Direct2D Clear/DrawBitmap Throwing Exception

In a C++ DLL I've got Direct2D initialized and then some draw functions. When calling pRenderTarget->Clear(...) it throws an AccessViolationException (Trying to access protected memory ...). Here ...
DaFuze's user avatar
  • 3
1 vote
0 answers
98 views

How to send a WM_IME_REQUEST message from C#

I'm working on an IME tool. To figure out the caret position of the foreground window, I'm supposed to use SendMessage() to send a WM_IME_REQUEST (0x0288) message, along with the parameters: wParam: ...
Simon Verbeke's user avatar

15 30 50 per page
1
2 3 4 5
253