C
ch_yahuu
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if findwindow('#32770',nil)<>0 then//我早找出他的类名了。
showmessage('oicq is running!')
else
showmessage('oicq is not running!');
end;
//上面的代码均成功。。但是下面要关它的时候,却关不了。。是不是窗口句柄找错了,但我找了多少次都是这一个。
没有办法了,只好贴出来由大家解决了。。。。
procedure TForm1.BitBtn2Click(Sender: TObject);
var cl:hwnd;
begin
cl:=findwindow('#32770',nil);
sendmessage(cl,wm_close,0,0);
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if findwindow('#32770',nil)<>0 then//我早找出他的类名了。
showmessage('oicq is running!')
else
showmessage('oicq is not running!');
end;
//上面的代码均成功。。但是下面要关它的时候,却关不了。。是不是窗口句柄找错了,但我找了多少次都是这一个。
没有办法了,只好贴出来由大家解决了。。。。
procedure TForm1.BitBtn2Click(Sender: TObject);
var cl:hwnd;
begin
cl:=findwindow('#32770',nil);
sendmessage(cl,wm_close,0,0);
end;
end.