Article ID: 161837
Article Last Modified on 7/15/2004
175510 : FILE: VB5DCOM.EXE: Using Callbacks and WithEvents with DCOM
266717 How To Create a DCOM Client/Server Application by Using VB
267836 How To Create a DCOM Client/Server with Events by Using VisualBasic
268550 How To Use Dcomcnfg for a Visual Basic DCOM Client/Server Application
269330 How To Troubleshoot DCOM for Visual Basic Client/Server Applications
Operating System Server Client
---------------- ------ ------
Windows 2000 Server YES YES
Windows 2000 Professional YES YES
WinNT 4.0 Server YES YES
WinNT 4.0 Workstation YES YES
Windows 98 YES* YES
Windows Me YES* YES
Windows 95 YES* YES:
with DCOM for Win95 files
* For more information about using Windows 95/98/Me for a DCOM Server.
Please see the following article in the Microsoft Knowledge Base:
165101 : How To Use Windows 95 or Windows 98 as a DCOM Server
C:\DCOMDemo C:\DCOMDemo\Server C:\DCOMDemo\Server\Setup C:\DCOMDemo\Client C:\DCOMDemo\Client\Setup
Control Name Property Value
------------------------------------------------------------------
Class Module Class1 (Name) clsDCOMDemoServer
Instancing 5 - MultiUse
Option Explicit
Public Function ServerTime()
'Retrieves the time from the server.
ServerTime = Time
End Function
Public Function AddNumbers(x As Integer, y As Integer) As Integer
'Receives two integers and adds them together.
AddNumbers = x + y
End Function
Public Function SubtractNumbers(x As Integer, y As Integer) _
As Integer
'Receives two integers and subtracts the second from the first.
SubtractNumbers = x - y
End Function
Project Type: ActiveX EXE (Create out-of-process
ActiveX component)
Startup Object: (None) (None required)
Project Name: proDCOMDemoServer (Will be used in client
code to define the project
to be used)
Help File Name: <Blank>
Project Help Context ID: 0
Project Description: DCOM Demo Project - Server
Unattended Execution: <Unchecked>
Upgrade ActiveX Controls: <Checked> (Enables upgrading of
ActiveX controls)
Auto Increment: <Checked> (Useful for version
comparison.)
Application Title: proDCOMDemoServer (Name of the EXE
that will be
compiled.)
Version Information: <As desired>
Command Line Arguments: <Blank>
Conditional Compilation Arguments: <Blank>
Compile to P-Code: <Selected> Compile to Native Code: <Not Selected>The rest of the options should be unavailable.
Start Mode: ActiveX Component Remote Server Files: <Checked> (Creates TLB and VBR files) Version Compatibility: Project Compatibility (Keeps GUIDs updated)Click OK.
Directory File Filename Extension
---------------------------------------------------------------------
C:\DCOMDemo\Server Class Module clsDCOMDemoServer .cls
Project proDCOMDemoServer .vbp
Control Name Property Value
------------------------------------------------------------------
Module Module1 Name modDCOMDemoClient
Form Form1 Name frmDCOMDemoClient
Caption DCOM Demo - Client
CommandButton Command1 Name cmdServerTime
Caption &Get Server Time
Command2 Name cmdComputeNumbers
Caption &Compute Numbers
Text Box Text1 Name txtX
TabStop True
TabIndex 0
Text2 Name txtY
TabStop True
TabIndex 1
Label Label1 Name lblAnswerAdd
Label2 Name lblAnswerSubtract
Label3 Name lblServerTime
You may want to add additional labels to the form to serve as captions
for these labels.
Option Explicit
Public oServer As New proDCOMDemoServer.clsDCOMDemoServer
Option Explicit
Private Sub Form_Load()
'Set initial values for text boxes.
txtX.Text = "1"
txtY.Text = "2"
End Sub
Private Sub txtX_GotFocus()
'Select all the text when the text box gets focus.
'This makes it easier to change the values.
txtX.SelStart = 0
txtX.SelLength = Len(txtX.Text)
End Sub
Private Sub txtY_GotFocus()
'Select all the text when the text box gets focus.
'This makes it easier to change the values.
txtY.SelStart = 0
txtY.SelLength = Len(txtY.Text)
End Sub
Private Sub cmdServerTime_Click()
'Get the time from the server and put it in the
'lblServerTime label.
lblServerTime.Caption = oServer.ServerTime
End Sub
Private Sub cmdComputeNumbers_Click()
'Passes the integers to the server and puts the answers in the
'appropriate labels. The "CInt" is to ensure that you are
'passing integers, which is what the server is expecting.
lblAnswerAdd.Caption = oServer.AddNumbers _
(CInt(txtX.Text), CInt(txtY.Text))
lblAnswerSubtract.Caption = oServer.SubtractNumbers _
(CInt(txtX.Text), CInt(txtY.Text))
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As _
Integer)
'Closes the object when the form unloads.
Set oServer = Nothing
End Sub
Project Type: Standard EXE (Client is a Standalone
executable)
Startup Object: frmDCOMDemoClient (frmDCOMDemoClient and
the code behind
the form run upon
execution)
Project Name: proDCOMDemoClient (Will be the name of the
client executable)
Help File Name: <Blank>
Project Help Context ID: 0
Project Description: DCOM Demo Project - Client
Unattended Execution: <Disabled>
Upgrade ActiveX Controls: <Checked> (Enables upgrading of
ActiveX controls)
Auto Increment: <Checked> (Useful for Version
checking)
Application Title: proDCOMDemoClient
Version Information: <As desired>
Command Line Arguments: <Blank>
Conditional Compilation Arguments: <Blank>
Compile to P-Code: <Selected> Compile to Native Code: <Not Selected>The rest of the options should be unavailable.
Directory File Filename Extension
----------------------------------------------------------------
C:\DCOMDemo\Client Module modDCOMDemoClient .bas
Form1 frmDCOMDemoClient .frm
Project proDCOMDemoClient .vbp
Rebuild the Project: <Unchecked> Options: Create a Setup ProgramClick Next.
Application Name: proDCOMDemoServer.clsDCOMDemoServer Application Type: Local Server Local Path: C:\WINNT\system32\proDCOMDemoServer.exe
Run application on the computer where the data is located <Unchecked> Run application on this computer <Checked> Run application on the following computer <Unchecked>
The Interactive User <Unselected> The Launching User <Selected> This User <Unselected>
Rebuild the Project: <Unchecked> Options: Create a Setup ProgramClick Next.
Remote Transport: Distributed COM (DCOM)
Network Address: <The name of the computer the server will be
installed on. Do not include backslashes>
Click OK. Click Next.
Keywords: kbhowto kbtophit kbautomation KB161837