Creation method:
1. Create a workspace
2. Create an application under workspace (assuming the name is myapp)
3. Create a custom class,
You can create a function in custom class.
4. Create a project
Select COM/MTS/COM + Component Wizard
Enter the Project name
Select a custom class
Set Interface Name
Set Program ID string
The default value is PB90. [custom class name]. We can modify it. (assume that it is changed to PB90.cus _ class7. This name is the class name called in pb)
Set Com Class Name
The default value is coclass _ [custom class name] (assuming coclass_cus_class7, this name is the class name called in VB)
Select register components upon successful build
5. generate DLL
Select the newly created Project, right-click, and click deploy
This completes the creation of COM.
Call method:
1. in VB
Create a VB project and add reference pb90 generated typelib for: MyApp. dll
Note that the red part is the output DLL file name, which is generally the same as the application name.
Write code:
Dim
As new myapp. COClass_cus_class7
MsgBox a. dog
Apparently, this COM is used through [Application name]. [com classname.
2, in Pb
Int intValue
Oleobject objOle
ObjOle = create OLEObject
IntValue = objOle. connecttonewobject ("PB90.cus _ class7 ")
If intValue = 0 then
String v
V = objOle. dog ()
Messagebox ("ss", v)
Endif
Apparently, this COM is used through [program id string.
Tests show that the calling methods in VB and Pb are different.