欢迎光临
我们一直在努力

C 关于ShowWindow的疑问,关于复活的疑问

IDE: Code::Blocks 16.01

操作系统:Windows 7 x64

?

最初的代码,目的是为了隐藏窗口出现在任务栏上的图标。

1 #include <windows.h> 2 3 using namespace std; 4 5 int main() 6 { 7 HWND hWnd; 8 9 /* Retrieves a handle to the foreground window (the window with which the user is currently working). */10 hWnd = GetForegroundWindow();11 12 /* Hides the window and activates another window. */13 ShowWindow(hWnd, SW_HIDE);14 15 return 0;16 }

?

Build > Run,确实是能隐美国高防vps藏。但似乎出现了一个Bug:Run之后,无法Abort!

好吧,只能开启Windows任务管理器,看了进程,没有出现相应的进程,无奈之下,只能关闭IDE,重新打开。

重复了几次,依旧如此!

?

后来对代码稍作修改:

1 #include <windows.h> 2 #include <conio.h> 3 #include <stdio.h> 4 5 using namespace std; 6 7 int main() 8 { 9 char cKey;10 HWND hWnd;11 12 /* Retrieves a handle to the foreground window (the window with which the user is currently working). */13 hWnd = GetForegroundWindow();14 15 /* Hides the window and activates another window. */16 ShowWindow(hWnd, SW_HIDE);17 18 cKey = getch();19 printf(“%c \n”, cKey);20 21 return 0;22 }

Build > Run,能隐藏,Run之后,仍然无法Abort!

好吧,开启Windows任务管理器,看了进程,相应的进程出现了,选择 > 结束进程。回到IDE,依旧无法Abort!What the hell? 还是得关闭IDE。

?

不知道是IDE的问题,还是ShowWindow()的问题导致这种情况。

转载于:https://www.cnblogs.com/Satu/p/8179915.html

39782047

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。