ipcclient.pp 773 B

1234567891011121314151617181920212223242526272829303132333435
  1. {$mode objfpc}
  2. {$h+}
  3. program ipcclient;
  4. uses sysutils,simpleipc;
  5. Var
  6. I,Count : Integer;
  7. DoStop : Boolean;
  8. begin
  9. Count:=1;
  10. With TSimpleIPCClient.Create(Nil) do
  11. try
  12. ServerID:='ipcserver';
  13. If (ParamCount>0) then
  14. begin
  15. DoStop:=(ParamStr(1)='-s') or (paramstr(1)='--stop');
  16. if DoStop then
  17. ServerInstance:=Paramstr(2)
  18. else
  19. ServerInstance:=Paramstr(1);
  20. if (Not DoStop) and (ParamCount>1) then
  21. Count:=StrToIntDef(ParamStr(2),1);
  22. end;
  23. Active:=True;
  24. if DoStop then
  25. SendStringMessage('stop')
  26. else for I:=1 to Count do
  27. SendStringMessage(Format('Testmessage %d from client',[i]));
  28. Active:=False;
  29. finally
  30. Free;
  31. end;
  32. end.