home *** CD-ROM | disk | FTP | other *** search
- unit TestImpl;
-
- interface
-
- uses
- Windows, ComObj, ActiveX, Srv_TLB, StdVcl;
-
- type
- TQTest = class(TAutoObject, IQTest)
- protected
- procedure SendText(const Value: WideString; Time: TDateTime); safecall;
- end;
-
- implementation
-
- uses ComServ, SysUtils;
-
- procedure TQTest.SendText(const Value: WideString; Time: TDateTime);
- const
- SFileName = 'c:\queue.txt';
- SEntryFormat = 'Send time: %s'#13#10'Write time: %s'#13#10'Message: %s'#13#10#13#10;
- var
- F: THandle;
- WriteStr: string;
- begin
- F := CreateFile(SFileName, GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL, 0);
- if F = INVALID_HANDLE_VALUE then RaiseLastWin32Error;
- try
- FileSeek(F, 0, 2); // go to EOF
- WriteStr := Format(SEntryFormat, [DateTimeToStr(Time), DateTimeToStr(Now), Value]);
- FileWrite(F, WriteStr[1], Length(WriteStr));
- finally
- CloseHandle(F);
- end;
- end;
-
- initialization
- TAutoObjectFactory.Create(ComServer, TQTest, Class_QTest,
- ciMultiInstance, tmApartment);
- end.
-