你试试,在一个Button的Click事件中加上:
procedure TForm1.Button1Click(Sender: TObject);
begin
keybd_event(18, MapVirtualKey(18, 0), 0, 0);//ALT键,我忘了虚键值.
keybd_event(VK_F4, MapVirtualKey(VK_F4, 0), 0, 0);
keybd_event(VK_F4, MapVirtualKey(VK_F4, 0), KEYEVENTF_KEYUP, 0);
keybd_event(18, MapVirtualKey(18, 0), KEYEVENTF_KEYUP, 0);
end;
你的程序关掉了,因为这相当于ALT+F4,呵呵...