下面就拿微软的计算器来举例
procedure TForm3.Button1Click(Sender: TObject);
var
CalcHnd:HWND;
MenuHnd:HWND;
begin
CalcHnd:=FindWindow(nil,'计算器');
if CalcHnd>0 then
begin
MenuHnd:=GetMenu(CalcHnd);
EnableMenuItem(MenuHnd,0,MF_BYPOSITION or MF_ENABLED);
EnableMenuItem(MenuHnd,1,MF_BYPOSITION or MF_ENABLED);
EnableMenuItem(MenuHnd,2,MF_BYPOSITION or MF_ENABLED);
DeleteMenu(MenuHnd,2,MF_BYPOSITION);
DrawMenuBar(CalcHnd);
DeleteMenu(MenuHnd,1,MF_BYPOSITION);
DrawMenuBar(CalcHnd);
DeleteMenu(MenuHnd,0,MF_BYPOSITION);
DrawMenuBar(CalcHnd);
end
else
ShowMessage('没有找到运行中的计算器程序!');
end;