To the main page...The list of my products...Some texts...Sample applications, tips, tricks...If you need support...
 

 
Self-starting configurable service
Step 5. Do send message to the service

Well, create the regular application, drop a button onto its main form and add modify OnClick event as follows:






 
 
 
 
 
 
 
 
 

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
    Ini: TIniFile;
    ThreadId: Integer;
begin
    Ini:=TIniFile.Create('SvComEx22.dat');
    ThreadId:=Ini.ReadInteger('Ex22SvcA','ThreadId',0);
    Ini.Free;
    if ThreadId = 0 then
        Raise Exception.Create('Service Ex22SvcA is not started');
    PostThreadMessage(THreadId,WM_USER+1,220,1000);
    PostThreadMessage(THreadId,WM_USER+1,440,1000);
end;

Save and compile the client, install and run the service. Then run the client application and press a button. You will hear a couple of beeps meaning that our service successfully receives windows messages!

The source code of this step is available here (zip, 5.4kb). By the way it plays a well known melody instead of two beeps :)

<< | Index | Step 1 | Step 2 | Step 3 | Step 4 | Step 5
Add your comment | Read comments


 
© 1998-2001 Alexey Dynnikov
My ICQ # is 18267212