PDA

View Full Version : چطور میشه server browser ساخت؟ (برای بازی)



ahmad009
دوشنبه 11 شهریور 1392, 11:46 صبح
چطور میشه server browser ساخت؟
که لیست تمام سرور های ایجاد شده در شبکه محلی رو نمایش بده و با یک کلیک بازی رو به اون سرور ها وصل کنه
به چه چیز هایی نیاز هست؟
با تشکر

bitasoft.ir
سه شنبه 12 شهریور 1392, 20:39 عصر
چطور میشه server browser ساخت؟
که لیست تمام سرور های ایجاد شده در شبکه محلی رو نمایش بده و با یک کلیک بازی رو به اون سرور ها وصل کنه
به چه چیز هایی نیاز هست؟
با تشکر

سلام
ببینین این قطعه کد به کار میاد؟



Imports OpcLabs.EasyOpc.DataAccess
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'display a message in the listbox to acknowledge that something is happening...
ListBox1.Items.Add("please wait...")
ListBox1.Update()

'now to do the opc server browsing
Try
'define our client object
Dim objEasyDA As New OpcLabs.EasyOpc.DataAccess.EasyDAClient

'this is the name of the computer we want to look at, where an empty string is the local machine
Dim strMachineName As String = ""

'now capture the browsed servers into a dictionary object
Dim ServerElements As OpcLabs.EasyOpc.ServerElementCollection = objEasyDA.BrowseServers(strMachineName)

'now clear any messages/items in the listbox
ListBox1.Items.Clear()

If Not ServerElements Is Nothing Then
'now iterate through each element within the dictionary
For Each key As Object In ServerElements.Keys
'now get the server element from the collection into a variable
Dim server As OpcLabs.EasyOpc.ServerElement = ServerElements.Item(key)
'add the progid of the opc server into the listbox
ListBox1.Items.Add(server.ProgId)
Next
End If

Catch ex As Exception
'display any exceptions in a messagebox
MessageBox.Show("Error: " & ex.Message)
End Try
End Sub
End Class