如何在 C++ 中将命令行字符串转换为 hwnd?

发布于 2024-12-23 07:18:26 字数 147 浏览 3 评论 0原文

我想使用 OpenGL 在 C++ 中创建屏幕保护程序。发送到我的应用程序用于在小窗口中预览屏幕保护程序的命令行包含一个数字,该数字是屏幕保护程序控制面板小程序中小监视器窗口的 hwnd 。如何将此字符串转换为有效的 hwnd

I want to create a screen saver in C++ using OpenGL. The command line sent to my app for previewing the screen saver in a small window contains a number which is the hwnd of the small monitor window in screen saver control panel applet. how can I convert this string to a valid hwnd?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生再见 2024-12-30 07:18:26

来自信息:屏幕保护程序命令行参数

是在命令行上以无符号十进制数形式呈现的 HWND。

因此,请将十进制数转换为 unsigned int,然后转换为 HWND。例如:

(HWND)atoi(argv[n])

其中 argv[n] 是找到 HWND 值的参数。

学究角:我对 atoi() 的使用可能还可以改进,因为命令行上的数字是无符号的。随意。

From INFO: Screen Saver Command Line Arguments:

<HWND> is a HWND presented on the command line as an unsigned decimal number.

So, convert the decimal number to an unsigned int and then cast to HWND. For example:

(HWND)atoi(argv[n])

where argv[n] is the argument where the HWND value is found.

Pedant's corner: My use of atoi() can probably be improved, since the number on the command line is unsigned. Feel free.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文