我知道如何通过以下代码在C#中隐藏控制台应用程序的窗口:
using System.Runtime.InteropServices;
//Insert below before the main function
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_HIDE = 0;
const int SW_SHOW = 5;
///End of before main
//now insert this under main function
var handle = GetConsoleWindow();
// Hide
ShowWindow(handle, SW_HIDE);
// Show
ShowWindow(handle, SW_SHOW);
现在的问题是,如何在C中而不是C ++中隐藏窗口?我一直在寻找解决方案,但所有这些都是我在C ++中找到的。
答案 0 :(得分:0)
所有WinAPI调用都是c声明(不是c ++)。
因此,您执行相同操作:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Confirm Box</h2>
<button onclick="myFunction()">Try it</button>
<input id="demo" />
<script>
function myFunction() {
var txt;
if (confirm("Press a button!")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
document.getElementById("demo").innerHTML = txt;
console.log(txt);
}
</script>
</body>
</html>