© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
116 replies
JimmahDean

❔ P/Invoked DeviceIoControl() works in C++ but does nothing in C#.

Code is attached.

I have scoured this for hours upon hours and cross checked the pointers with the working C++ version and everything matches. The call doesn't error, checking LastWin32Error, LastSystemError and LastPInvokeError all return "The operation completed successfully." and the return length of the data retrieved is the same in C# as it is in C++, even checked in ProcMon that both apps were making the same system calls and they are. The call happens successfully as it should, but zero data is retrieved in the C# version.

I'm at my wits end here.
Program.cs10.02KB
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ How does CultureInfo works in C#?
C#CC# / help
11mo ago
❔ trying to move up + downwards but nothing really works
C#CC# / help
3y ago
✅ LoadLibrary works, but does not show in Debug>Windows>Modules tab
C#CC# / help
3y ago
Console.WriteLine does nothing
C#CC# / help
2y ago