欢迎光临散文网 会员登陆 & 注册

用Rust调用winapi关闭显示器

2022-06-02 23:05 作者:Tuple_元组  | 我要投稿

本文介绍如何在Rust语言中调用winapi,并发送关闭显示器消息。相关程序代码示例如下:

程序中:secound表示程序延时多少秒后,再发送关闭显示的消息。

              需要使用unself{}来执行可能不安全的代码。

              PostMessageA的解释是:Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.

该段代码 使用 cargo build --release 编译后,生成的二进制可执行文件大小为140K,相比用C++写同样功能的程序体积还是大的。后者仅为11K。

用Rust调用winapi关闭显示器的评论 (共 条)

分享到微博请遵守国家法律