home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue55 / ccorn / TestImpl.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2000-02-07  |  1.0 KB  |  42 lines

  1. unit TestImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ComObj, ActiveX, Srv_TLB, StdVcl;
  7.  
  8. type
  9.   TQTest = class(TAutoObject, IQTest)
  10.   protected
  11.     procedure SendText(const Value: WideString; Time: TDateTime); safecall;
  12.   end;
  13.  
  14. implementation
  15.  
  16. uses ComServ, SysUtils;
  17.  
  18. procedure TQTest.SendText(const Value: WideString; Time: TDateTime);
  19. const
  20.   SFileName = 'c:\queue.txt';
  21.   SEntryFormat = 'Send time:  %s'#13#10'Write time: %s'#13#10'Message: %s'#13#10#13#10;
  22. var
  23.   F: THandle;
  24.   WriteStr: string;
  25. begin
  26.   F := CreateFile(SFileName, GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_ALWAYS,
  27.     FILE_ATTRIBUTE_NORMAL, 0);
  28.   if F = INVALID_HANDLE_VALUE then RaiseLastWin32Error;
  29.   try
  30.     FileSeek(F, 0, 2);  // go to EOF 
  31.     WriteStr := Format(SEntryFormat, [DateTimeToStr(Time), DateTimeToStr(Now), Value]);
  32.     FileWrite(F, WriteStr[1], Length(WriteStr));
  33.   finally
  34.     CloseHandle(F);
  35.   end;
  36. end;
  37.  
  38. initialization
  39.   TAutoObjectFactory.Create(ComServer, TQTest, Class_QTest,
  40.     ciMultiInstance, tmApartment);
  41. end.
  42.