function SendCommandData(const Msg: string): Boolean;<br>var<br> nServiceWnd: THandle;<br> cData: TCopyDataStruct;<br>begin<br> Result := False;<br> nServiceWnd := FindWindow(defServiceClassName, nil);<br> if nServiceWnd = 0 then<br> nServiceWnd := StartServiceWin;<br> if nServiceWnd <> 0 then<br> begin<br> cData.cbData := Length(Msg);<br> cData.dwData := 0;<br> cData.lpData := PChar(Msg);<br> SendMessage(nServiceWnd, WM_COPYDATA, WPARAM(Application.Handle), LPARAM(@cData)); { 异步发送,省的阻塞 }<br> Result := True;<br> end;<br>end;