简体   繁体   中英

How to convert a command line string to hwnd in C++?

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM