-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add SetConsoleMode to windows.kernel32 #15039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi, and thank you for your contribution! Our general direction when it comes to Windows system API is to rely mainly on direct calls into the |
I'd like to try. If it's easy enough, should I reimplement GetConsoleMode too? |
My suggestion is to first focus on one, and if it goes well you are more than welcome to tackle others. |
Here's ReactOS' implementation that might be useful https://github.com/reactos/reactos/blob/2ae45e0985ba55a50f86a88a25067d937fcd3062/dll/win32/kernel32/client/console/console.c#L1606 |
This is almost guaranteed to run into the same problems encountered in #14411 (specifically #14411 (comment) and #14411 (comment)) when it comes to a The good news is that if you just want to use const std = @import("std");
pub extern "kernel32" fn SetConsoleMode(in_hConsoleHandle: std.os.windows.HANDLE, in_dwMode: std.os.windows.DWORD) callconv(std.os.windows.WINAPI) std.os.windows.BOOL;
pub fn main() !void {
_ = SetConsoleMode(std.io.getStdIn().handle, 0x10);
} (and here's a larger / real-world example of using many win32 bindings not in the standard library) |
Thanks for the links and the example showing that I don't need to patch the |
This is what I've done so far. What is missing:
Theoretically, I could copy the entire If anyone has suggestions (or values/implementations), I could put more work into it. As an additional info:
|
First, to answer some questions:
Second, I think it's worth offering some warning:
|
Currently, I know that I don't need to patch I'm not sure how useful "my implementation" would be (I'm guessing not that useful, basing on what you said). I'm planing on closing this, thanks again for all links and suggestions. (I'm not sure if closing disallows anything important, like any closing thoughts. |
Until such time we gather compelling evidence we need such a wrapper, I am closing this PR for now. Feel free to re-open or submit a new one if you disagree or find a compelling use case! |
Hi,
I've read that
windows.kernel32
's functions are "lazily added" tostdlib
.I would like to use
SetConsoleMode
in my project.I have already patched
stdlib
in my local machine and looks like it works.