initial commit
[rofl0r-KOL.git] / units / ipcstreams / ipcstreams_anonymouspipes_demo / Kol_AnonymousServer.pas
blobf8b1fa54ebf9ea1e84a724fd560064e30196e521
1 {-----------------------------------------------------------------------------
2 Unit Name: Kol_AnonymousServer
3 Author: Thaddy de Koning
4 Purpose: Demo Anonymous Pipe streams from kolipcstreams.pas
5 History: February 17, 2003, Initial release
6 -----------------------------------------------------------------------------}
9 unit Kol_AnonymousServer;
10 //********************************************************************
11 // Created by KOL project Expert Version 2.00 on:13-2-2003 16:56:56
12 //********************************************************************
15 interface
16 uses
17 Windows, Messages, Kol, KolIPCStreams;
19 type
21 PForm1=^TForm1;
22 TForm1=object(Tobj)
23 Form:pControl;
24 Button,
25 Memo:pControl;
26 NPS:pStream;
27 private
28 Thread:pThread;
29 Fstring:string;
30 public
31 function ThreadExecute(sender:pThread):integer;
32 procedure BtnClick(sender:pObj);
33 procedure UpdateMemo;
34 procedure WriteString(const S:string);
35 end;
39 procedure NewForm1( var Result: PForm1; AParent: PControl );
41 var
42 Form1:pForm1;
44 implementation
46 procedure NewForm1( var Result: PForm1; AParent: PControl );
47 begin
48 New(Result,Create);
49 with Result^ do
50 begin
51 Form:= NewForm(AParent,'KOLForm').SetSize(600,400).centeronparent.Tabulate;
52 Applet:=Form;
53 Form.Add2AutoFree(Result);
54 NPS:=NewAnonymousPipeReadStream('KolAnonimousClient.exe',true);
55 Form.Add2AutoFree(NPS);
56 Memo:=NewEditBox(Form,[eoMultiline]);
57 Memo.Width:=300;
58 Button:=NewButton(Form,'Read').placeright.resizeparent;
59 Button.OnClick:=btnClick;
60 end;
61 end;
63 procedure Tform1.BtnClick(sender:pObj);
64 begin
65 Thread:=NewThreadAutoFree(ThreadExecute);
66 end;
69 function Tform1.ThreadExecute(sender:pThread):integer;
70 var
71 TempStr:STring;
72 Count:Dword;
73 begin
74 SetLength(TempStr,1024);
75 Count:=NPS.Read(TempStr[1],Length(TempStr));
76 SetLength(TempStr,Count);
77 Writestring(TempStr);
78 end;
80 procedure Tform1.UpdateMemo;
81 begin
82 Memo.Text:=FString;
83 end;
85 procedure Tform1.WriteString(const S:string);
86 begin
87 FString := S;
88 Thread.Synchronize(UpdateMemo);
89 end;
91 end.