gpt4 book ai didi

c - 如何禁用C中的关闭按钮?

转载 作者:可可西里 更新时间:2023-11-01 14:13:54 27 4
gpt4 key购买 nike

有谁知道如何使用从 C 程序创建的 .exe 可执行文件禁用 Windows 控制台窗口上的关闭按钮?

最佳答案

来自 here:

#define _WIN32_WINNT 0x0500
#include <stdio.h>
#include <windows.h>

int main(int argc, _TCHAR* argv[]){
HWND h;
HMENU sm;
int i, j, c;
LPTSTR buf;
// get the handle to the console
h = GetConsoleWindow();
// get handle to the System Menu
sm = GetSystemMenu(h, 0);
// how many items are there?
c = GetMenuItemCount(sm);
j = -1;
buf = (TCHAR*) malloc (256 *sizeof(TCHAR));
for (i=0; i<c; i++) {
// find the one we want
GetMenuString(sm, i, buf, 255, MF_BYPOSITION);
if (!strcmp(buf, "&Close")) {
j = i;
break;
}
}
// if found, remove that menu item
if (j >= 0)
RemoveMenu(sm, j, MF_BYPOSITION);
return 0;
}

关于c - 如何禁用C中的关闭按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12002041/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com