记事本与计算器的调用

procedure TMain.N8Click(Sender: TObject);
var
  OFile:String;
  HWndCalculator:HWnd;
begin
  HWndCalculator:=FindWindow(nil,'计算器');
  if (HWndCalculator=0) then
  begin
    OFile:='calc.exe';
    Shellexecute(handle,'Open',pchar(OFile),nil,pchar(ExtractFilePath(OFile)),SW_SHOWNORMAL);
  end;
end;

procedure TMain.N9Click(Sender: TObject);
var
  OFile:String;
  HWndCalculator:HWnd;
begin
  HWndCalculator:=FindWindow(nil,'记事本');
  if (HWndCalculator=0) then
  begin
    OFile:='NOTEPAD.EXE';
    Shellexecute(handle,'Open',pchar(OFile),nil,pchar(ExtractFilePath(OFile)),SW_SHOWNORMAL);
  end;
end;

posted @ 2012-05-21 21:04  Unique.Y  阅读(172)  评论(0编辑  收藏  举报