COM ActiveX   3GL   4GL

- , , , DLL.
- , - -. , Microsoft Word, Microsoft Excel, Microsoft Internet Explorer . Delphi . , . -.
( ) - -, , IDispatch.
, . , C++, Object Pascal (Delphi) Visual Basic.
, Delphi .
IDispatch
-, IDispatch. system :
type
IDispatch = interface (IUnknown)
[' {00020400-0000-0000--000000000046} ' ]
function GetTypelnfoCount(out Count: Integer): Integer; stdcall;
function GetTypelnfo(Index, LocalelD: Integer; out Typelnfo):Integer; stdcall;
function GetlDsOfNames(const IID: TGUID; Names: Pointer; NameCount, LocalelD: Integer; "
DispIDs: Pointer): Integer; stdcall;
function Invoke(DispID: Integer; const IID: TGUID; LocalelD: Integer; Flags: Word;
var Params; VarResult, Exceptlnfo, ArgErr: Pointer): Integer;
end;

IDispatch invoke. - . , , invoke Displo. , (dispatch ID). , . invoke - IID . LocalelD . Flags , : , . Params TDispparams. , . VarResult olevariant, ( ), Excepinfo - TExcepinfo, , invoke DISP_E_EXCEPTION. ArgError - , Params. invoke DISP_E_TYPEMISMATCH DISP_E_PARAMNOTFOUND.
invoke - GetlDsOfNames. , . IID . Names - . PWideChar. NameCount , , Names. LocalelD . Displos - NameCount.
GetTypelnfo . index () . LCID . , Typeinfo iTypeinfo .
GetTypeinfoCount , . count. : 0, , 1, .

, (late binding) (early binding).
invoke IDispatch. , invoke. IDispatch, invoke. invoke .
, , IDispatch. , invoke IDispatch. .
(dual interface). , invoke, IDispatch. , Delphi, . , Delphi, invoke.

. , .

e
, Delphi. Delphi 5 Servers (), , , .

, :
1. Delphi Project/Import Type Library (/ ).
2. (. 3.13) .


, . , Add (). Add (), TLB, OLB, DLL, OCX EXE. Remove (). Remove ().


 3.13
. 3.13.
3. Palette page ( ) Delphi, .
4. , Generate Component Wrapper ( ) .
5. Install ().

, . , Delphi:
1. .
2. , Events - .
3. , Delphi , .
, .

, Microsoft Word, Microsoft Excel Microsoft Outlook, Microsoft Office. , .
, Microsoft Office.
Microsoft Office , . . , Microsoft Office . Microsoft Word word.Application, Microsoft Excel - Excel.Application. Microsoft Outlook outLookAppiication, , , Application , , , .
Microsoft Office , . Run, Activate .


. Microsoft Office . .

. 3.14 Microsoft Word Object. Microsoft Office Microsoft Office.

 3.14
. 3.14. Microsoft Word Object
, Microsoft Office, , . . , .
, Microsoft Office Application. Delphi.


, ( ) Delphi.

, :
1. Delphi File/New Application (/ ).
2. wordApplication Servers Delphi.
3. AutoConnect AutoQuit WordAppiication
true ( ).
4. Run/Run (/).
, , , . Microsoft Word. , , Windows . <Ctrl>+<Alt>+<Del> , , Windows, Winword.exe.
, :
- , Windows WordApplication (CLSID);
- , , Windows;
- ( ) , Microsoft Word.
, Windows. IDispatch ( _ADDRef, , ).
, , 3.1. Start Finish.

3.1
unit Unitl;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics', Controls, Forms, Dialogs, StdCtrls, COMObj;
type
TForml = class(TForm)
Start: TButton;
Finish: TButton;
procedure StartClickfSender: TObject);
procedure FinishClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Forml: TForml;
wd:01eVariant;
fileName:string;
implementation {$R *.DFM}
procedure TForml.StartClick(Sender: TObject);
begin
try
fileName:=ExtractFilePath(Application.EXEName)+'report.DOC';
//
wd:=Create01eObject('Word.Application');
//
wd.application.documents.add;
wd.application.activedocument.range.insertAfter(now);
wd.application.activedocument.saveas(fileName);
except
end;
end;

procedure TForml.FinishClick(Sender: TObject);
begin
//
wd.application.quit(true,0);
end;
end.


coMObj Uses.
, Servers . , , Microsoft Word (WordDocument), Excel (ExcelWorkbook) .
, , Servers, TOLEServer, , , TComponent. TOLEServer - -, . , -. , Autoconnect, , , true, - .
ConnectKind ( ). Connect, AutoConnect=true. . 3.6 ConnectKind.
3.6. , ConnectKind


ConnectKind

CkRunningOrNew


. , - . .

CkNewInstance


CkRunninglnstance

, , -

CkRemote

, . ConnectKind RemoteMachineName

CkAttachToInterface

, true AutoConnect. ConnectTo




ConnectKind - CkAttachToInterface- , wordDocument WordFont. , , .

ConnectKind , .

ConnectKind . :
1. File/New Application (/ ) .
2. wordApplication wordDocument, Servers.
3. AutoConnect AutoQuit WordApplication true.
4. ConnectKind WordDocument CkAttachToInterface.
5. wordApplication Events ().
6. onDocumentchange , Delphi, 3.2

.2
procedure TForml.WordApplicationlDocumentChange(Sender: TObject);
begin
// Microsoft Word
WordDocumentl.ConnectTo(WordApplicationl.ActiveDocument};
//
WordDocumentl.Range.InsertAfter(#13+' '+#13+
WordApplicationl.ActiveDocument.Get_FullName+' :'+
DateTimeToStr(Now));
end;


, , 3.2. -, Microsoft Word. ( , Microsoft Word) ConnectTo . , InsertAfter . (#13). Get_FullName Microsoft Word.
7. Create , 3.3.

.3
procedure TForml.FormCreate(Sender: TObject);
begin
//
WordApplicationl.Visible:=true;
end;


Microsoft Word , .
Run/Run (/). Microsoft Word. Microsoft Word File/New (/) . , . Microsoft Word Window (). , .
, Microsoft Excel. Microsoft Excel , OnNewworkBook.

, DLL. , .
1. DLL, . .
2. .
3. . , .
4. . .
, . Delphi File/New Application (/ ).
, . , File/New (/). New Items ( ) ActiveX (. 3.15).
Automation Object ( ) . Automation Object Wizard ( ) (. 3.16).

 3.15
. 3.15. ActiveX New Items

 3.16
. 3.16. Automation Object Wizard
Auto CoClass Name - . , Object Pascal , i - .
- .
Delphi , , , . , , , . . 3.17 Automation Object Wizard ( ).

 3.17
. 3.17.
3.4 , Delphi.

3.4.
unit Unit2; interface
uses
ComObj, ActiveX, Projectl_TLB, StdVcl;
type
TAuto = class(TAutoObject, lAuto)
protected
{ Protected declarations }
end;
implementation
uses ComServ;
initialization
TAutoObjectFactory.Create(ComServer, TAuto, Class_Auto,ciMultilnstance, tmApartment);
end.


, TAuto - TAutoObject. , TAutoobject .
, TAuto lAuto .
. , . color lAuto. , :
- lAuto ;
- . . , , , , Write Only ( ) (. 3.18);
- color OLE_COLOR .

 3.18
. 3.18. lAuto
. , Refresh Implementation (. 3.19). Delphi , . 3.5. , TAuto.Set_Color.

3.5
unit Unit2;
interface
uses
ComObj, ActiveX, TestJTLB, StdVcl;
type
TAuto = class(TAutoObject, lAuto)
protected
procedure Set_Color(Value: OLE_COLOR); safecall;
{ Protected declarations }
end;
implementation
uses ComServ, Unitl;
procedure TAuto.Set_Color(Value: OLE_COLOR);
begin
Forml.color:=Value;
end;
initialization
TAutoObjectFactory.Create(ComServer, TAuto, Class_Auto, ciMultilnstance, tmApartment);
end.


. , , Automation. . , Test. , Test.exe.
, . , , . File/Close All (/ ) File/New Application. : (. 3.20).

 3.19
. 3.19.

 3.20
. 3.20.
3.6 .

3.6
unit Unitl;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, TestJTLB;
type
TForml = class(TForm)
Buttonl: TButton;
Button2: TButton;
procedure ButtonlClick(Sender: TObject);
procedure,Button2Click(Sender: TObject);
private
FIntf: lAuto;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation {$R *.DFM}
procedure TForml.ButtonlClick(Sender: TObject);
begin
FIntf:=CoAuto.create ;
end;
procedure TForml.Button2Click(Sender: TObject);
begin
FIntf.Set_Color(clRed);
end;
end.

. , uses Test_TLB. private FIntf lAuto. Onclick, . Test.exe. Onclick , set_color lAuto. , , clRed -. . . , Test.exe, Test.exe .
, (. 3.21).

 3.21
. 3.21.

  COM ActiveX   3GL   4GL

, - , , . , , size.
{DATA}




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution