A simple little example showing how to instantiate a PB COM Server in VB6. All source code is included in a zip file at the bottom of this post.
You must first register the server vbt.dll with
PBWin 9 Server vbt.bas:
PBWin 9 Resource vbt.rc:
VB Project1.vbp
VB Form1.frm
You must first register the server vbt.dll with
Code:
regsvr32 vbt.dll
PBWin 9 Server vbt.bas:
Code:
#COMPILE DLL #DIM ALL #COM NAME "VBTst" #COM TLIB ON #RESOURCE "vbt.pbr" CLASS CVBT GUID$("{1F8B0CB3-A491-4336-A133-5BA8CC6F7C8A}") AS COM INTERFACE IVBT GUID$("{B1E286E4-0588-43F0-9D94-2F0F5B72218D}") INHERIT IDISPATCH PROPERTY GET GetTime AS STRING PROPERTY = UCODE$(TIME$) END PROPERTY END INTERFACE END CLASS
Code:
#include "resource.h" 1 typelib "vbt.tlb"
Code:
Type=Exe Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINDOWS\system32\stdole2.tlb#OLE Automation Reference=*\G{955F2417-1292-451F-88FF-1DE8EE42E989}#1.0#0#vbt.dll#COM Library Form=Form1.frm Startup="Form1" ExeName32="Project1.exe" Command32="" Name="Project1" HelpContextID="0" CompatibleMode="0" MajorVer=1 MinorVer=0 RevisionVer=0 AutoIncrementVer=0 ServerSupportFiles=0 CompilationType=0 OptimizationType=0 FavorPentiumPro(tm)=0 CodeViewDebugInfo=0 NoAliasing=0 BoundsCheck=0 OverflowCheck=0 FlPointCheck=0 FDIVCheck=0 UnroundedFP=0 StartMode=0 Unattended=0 Retained=0 ThreadPerObject=0 MaxNumberOfThreads=1 [MS Transaction Server] AutoRefresh=1
Code:
VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default Begin VB.TextBox Text1 Height = 495 Left = 240 TabIndex = 1 Text = "Text1" Top = 120 Width = 1215 End Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 1680 TabIndex = 0 Top = 120 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim o As CVBT Dim s As String Set o = CreateObject("CVBT") s = o.GETTIME Text1.Text = s End Sub
Comment