Delphi - 隐藏控制台窗口 [英] Delphi - Hide console window
本文介绍了Delphi - 隐藏控制台窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
和GetConsoleWindow
WinAPi
尝试此示例
{$ APPTYPE CONSOLE}
使用
Windows,
SysUtils;
函数GetConsoleWindow:HWND;标准外部kernel32;
开始
尝试
Writeln('按Enter隐藏控制台窗口');
Readln;
//隐藏控制台窗口
ShowWindow(GetConsoleWindow,SW_HIDE);
//做某事
睡眠(5000);
Writeln('按enter键退出');
//显示控制台窗口
ShowWindow(GetConsoleWindow,SW_SHOW);
Readln;
除了
在E:Exception do
Writeln(E.ClassName,':',E.Message);
结束
结束。
Possible Duplicate:
Profiler and Memory Analysis Tools for Delphi
How do I hide the console window?I'm reposting this to make it more clear. So, here is my console application:
That opens a socket to 127.0.0.1:81, when the console application is visible it works fine, now how do I keep it working fine as a console but make the console invisible?
I am using Delphi 2007 (7).
Thanks.
解决方案You can use
ShowWindow
and theGetConsoleWindow
WinAPi functions.Try this sample
{$APPTYPE CONSOLE} uses Windows, SysUtils; function GetConsoleWindow: HWND; stdcall; external kernel32; begin try Writeln('Press enter to hide console the window'); Readln; //hide the console window ShowWindow(GetConsoleWindow, SW_HIDE); //do something Sleep(5000); Writeln('Press enter to exit'); //show the console window ShowWindow(GetConsoleWindow, SW_SHOW); Readln; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
这篇关于Delphi - 隐藏控制台窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文