procedure TForm1.Button1Click(Sender: TObject);
var
hdw,hdb:THandle;
en:BOOL;
begin
hdw:=FindWindow( nil,'TestForm'); //得到窗口句柄
if hdw=0 then
begin
ShowMessage('TestForm not find!');
exit;
end;
hdb:=FindWindowEx(hdw,0,nil,'Button1'); // //得到按钮句柄
if hdw=0 then
begin
ShowMessage('Button1 not find!');
exit;
end;
en:=isWindowEnabled(hdb); //是否enable(灰)
if en then
ShowMessage('Button1 Enabled!')
else
ShowMessage('Button1 Disabled!')
end;