home *** CD-ROM | disk | FTP | other *** search
- unit MyAuto;
-
- { This object has one method and one property that are available via OLE
- automation. The property allows you to set the value of a string, and
- the method shows the string in a dialog.
-
- For this example to work, you need to run the TestAp program, stored in this
- same directory. Before running TestAp, you should run this program once,
- passing in /regserver as the program's sole parameter.
-
- Open up the DPR file to see the call to Automation.ServerRegistration. }
-
- interface
-
- uses OleAuto;
-
- type
- TMyAuto = class(TAutoObject)
- private
- FMyProp: string;
- function GetMyProp: string;
- procedure SetMyProp(S: string);
- public
- constructor Create; override;
- automated
- procedure ShowDialog;
- property MyProp: string read GetMyProp write SetMyProp;
- end;
-
- implementation
-
- uses
- Dialogs;
-
- constructor TMyAuto.Create;
- begin
- inherited Create;
- end;
-
- procedure TMyAuto.ShowDialog;
- begin
- if FMyProp = '' then
- FMyProp := 'This object has a property called MyProp';
- ShowMessage(FMyProp);
- end;
-
- procedure TMyAuto.SetMyProp(S: string);
- begin
- FMyProp := S;
- end;
-
- function TMyAuto.GetMyProp: string;
- begin
- Result := FMyProp;
- end;
-
- procedure RegisterMyAuto;
- const
- AutoClassInfo: TAutoClassInfo = (
- AutoClass: TMyAuto;
- ProgID: 'AUTOPROJ.MyAuto';
- ClassID: '{FE67CF61-2EDD-11CF-B536-0080C72EFD43}';
- Description: 'Sam';
- Instancing: acMultiInstance);
- begin
- Automation.RegisterClass(AutoClassInfo);
- end;
-
- initialization
- RegisterMyAuto;
- end.