Is there any change of getting console title name instead of renaming it? I know that I can use ie ctypes.windll.kernel32.SetConsoleTitleW to set new title of the console but I just want to get title name and do not set new title.
不出所料,伴随函数是GetConsoleTitleW
。
Calling GetConsoleTitleW
is not enough to obtain the console title. Instead, you first need to create a buffer to hold that data and pass that. Then, return the buffer's value.
The following function will return the console title:
import ctypes
def get_console_title():
BUF_SIZE = 256
buffer = ctypes.create_unicode_buffer(BUF_SIZE)
ctypes.windll.kernel32.GetConsoleTitleW(buffer, BUF_SIZE)
return buffer.value
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.