線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1282
推到 Plurk!
推到 Facebook!

如何隐藏別人的程序

尚未結案
vagrant
一般會員


發表:29
回覆:72
積分:20
註冊:2003-07-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-05-16 20:15:46 IP:221.4.xxx.xxx 未訂閱
因为别人的某个程序A(没有源代码)必须开着,显示在状态区或 者任务栏很容易误关掉,因此需要写个程序把A程序隐藏起来, 不出現在状态区或者任务栏就行了, 所用代碼如下,可以實現不在任務欄,但卻出現在狀態欄上 應該如何修改代碼呢?謝謝! TForm1.Button1Click(Sender: TObject); var aHandle:THandle; ExtendedStyle:integer; begin aHandle:=FindWindow(nil,'Program Title'); IF aHandle>0 then begin showmessage('Find OK'); ShowWindow(aHandle,SW_HIDE); ExtendedStyle := GetWindowLong (aHandle, GWL_EXSTYLE); SetWindowLong(aHandle, GWL_EXSTYLE, ExtendedStyle OR WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW and not WS_EX_NOPARENTNOTIFY); end;
chris_shieh
高階會員


發表:46
回覆:308
積分:240
註冊:2004-04-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-05-16 23:19:13 IP:220.137.xxx.xxx 未訂閱
請參考 wameng  http://delphi.ktop.com.tw/topic.php?TOPIC_ID=56662    
    unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;    type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;    var
  Form1: TForm1;
  hProgram:THandle;    implementation    {$R *.DFM}    //Hide
procedure HideProgram(hWnd:THandle);
var
  ExStyle:Longint;
begin
  ShowWindow(hWnd,SW_HIDE);
  ExStyle:=GetWindowLong(hWnd,GWL_EXSTYLE);
  ExStyle:=ExStyle or WS_EX_TOOLWINDOW;
  SetWindowLong(hWnd,GWL_EXSTYLE,ExStyle);
end;    //Show
procedure ShowProgram(hWnd:THandle);
var
  ExStyle:Longint;
begin
  ShowWindow(hWnd,SW_SHOW);
  ExStyle:=GetWindowLong(hWnd,GWL_EXSTYLE);
  ExStyle:=ExStyle and (Not WS_EX_TOOLWINDOW);
  SetWindowLong(hWnd,GWL_EXSTYLE,ExStyle);
end;    procedure TForm1.Button1Click(Sender: TObject);
var
   hwnd:THandle;
begin
   hwnd:=FindWindow(nil, '未命名 - 記事本');
   if hwnd>0 then
   begin
      hProgram:=hwnd;
      HideProgram(hwnd);
   end;
end;        procedure TForm1.Button2Click(Sender: TObject);
begin
   ShowProgram(hProgram);
end;    
發表人 - Chris_Shieh 於 2005/05/16 23:31:54
系統時間:2024-05-07 13:01:36
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!