Example: DSServer Control

NI DataSocket

Example: DSServer Control

Programatically controls a DataSocket server through automation.

Description

If you have an application that uses the DataSocket server, you might want to launch the server, hide it, show it, or close it directly from that application. This example shows you the automation interface that you can use to programmatically control a local DataSocket server.

First, create an object that can reference a DataSocket server:

Dim cwdss As CWDataServer.CWDataServer

With the previous line of code, you have an object named cwdss that can hold a reference to a DataSocket server.

Now you need to reference an instance of the server. The following line of code either launches a new instance, if one doesn't already exist, or gets a reference to one running:

Set cwdss = New CWDataServer.CWDataServer

At this point, you can call the Show, Hide, and Close methods on the cwdss object.

MethodDescription
ShowShows the referenced DataSocket server. You must have a reference to a DataSocket server before calling the Show method.
HideHides the referenced DataSocket server. You must have a reference to a DataSocket server before calling the Hide method.
CloseCloses the DataSocket server. The DataSocket server will not close until all objects referencing it are closed.

Note: Close object references. For example, you can set your object, cwdss, to Nothing.

Example Location

Samples\DataSocket