function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer; stdcall; external 'KERNEL32.DLL';
在Form的create事件中加入
  RegisterServiceProcess(GetCurrentProcessId,1);
在Form的事件中加入
  RegisterServiceProcess(GetCurrentProcessId,0);
其实这个问题在http://expert.csdn.net/Topic/10269.shtm
里面早已解决了