procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
在程序运行的初期,首先激活窗体FormCreate()过程中的代码,通过SetWindowLong (Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW)这条语句就可以实现从系统任务条上隐藏本程序的功能。
程序代码如下:
unit Unit1;
interface
uses
windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
end.
保存文件,然后按F9键运行程序。