Simple COM Example (for Delphi)
1. Open Delphi 5.0 program
2. Close all units
II. Click "File" on the "New" submenu under the menu, pop up the "New Item" dialog box, select "ActiveX Library" under "ActiveX", click OK. (This action creates a "library project")
4. Save the "this project" as "comprogramexap".
5. Click "File" on the "New" submenu under the menu, pop up the "New Item" dialog box, select "COM Object" under "ActiveX", click OK. (This action creates a "COM object")
Bread, "Com object wizard" dialog,
Enter the Class (Class) Name - "Z_ComproExacla", click "OK".
Pop up, "Comprogramexap.TLB" dialog,
Select "IZ_COMPROEXACLA", add "Properties, Method" below, add "Method 1" - "Z_MethodAdd"
Give this "z_methodadd" method, enter parameters
Refresh
The parameters are complete, click Refresh.
Add, method content,
Method content
Finally, register for COM,
registered
6. The end of the production.
For delphi
I. New construction
II. Join the interface
II. Click "Project" to "Import Type Library" submenu under the menu, pop up the "Import Type Library" dialog, select "ComprogramexAP Library, click" CREATE "button.
"Uses comprogramexap_tlb;" unit
V. Making applications
application
Sixth.
Application (for VB)
Seven. New project
Eight. Join the interface
9. Click "Project" to "References" submenu under the menu, pop up the "References-Project1.vbp" dialog box, select "ComprogramXAP Library, click" OK "button.
Ten. Production application
Private submmand1_click ()
Class interface (unable to declare the project)
'
statement
- interface > - variable DIM Z_COMTEST AS New Z_COMPROEXACLA DIM A, B AS INTEGER 'Application A = text1 B = Text2 Text3 = z_comtest.z_methodadd (A, B) End Sub XI.