Click to Rate and Give Feedback
MSDN
MSDN Library
Virtualization
 Connecting to the Virtual Server CO...

  Switch on low bandwidth view
Connecting to the Virtual Server COM Object

The Virtual Server programming interface is a standard COM object. Before any of the interfaces are accessed, the COM layer is initialized, the default security access level is set, and a pointer to the main IVMVirtualServer object is obtained. All other Virtual Server objects are accessed through this primary interface.

The Virtual Server COM interfaces can only be accessed if the COM Security level is set to Impersonation level or higher. By default, COM uses the Identification security level if no level is explicitly specified. To set the COM security level, the user's program should make a call to CoInitializeSecurity immediately after the initial CoInitializeEx call and before any of the Virtual Server's interfaces are accessed.

The multithreaded apartment model should be used for applications using the Virtual Server COM interfaces. Using the single-threaded apartment model with the Virtual Server COM interface can significantly affect the Virtual Server system's performance.

The various Event interfaces are used by Virtual Server to communicate asynchronous status and state change information back to the application program. If the client application is run remotely, the DCOM service must be properly configured to work through any firewalls and routers which exist between the server and the client program. A white paper titled "Using Distributed COM with Firewalls" by Michael Nelson can be found in the Microsoft COM Web site in the white papers section. This article details the steps required to configure DCOM to work through firewalls.

Accessing Virtual Server using Visual C#

Visual C# and .NET normally handles all the initialization and marshalling of the COM interface layer. To change the COM security level, the CoInitializeSecurity must be called directly at the very beginning of the program, before any type of COM marshalling has been performed.

The following example program illustrates the steps required to initialize and access the Virtual Server COM object. It displays the name and version number of the Virtual Server COM object.

The following steps must be performed to set up the build environment:

  1. Create a new Windows Applications project called ShowVSVersion. Form1 is created by default.
  2. Add a class to the project. Class1 is created by default.
  3. Add the reference to the Virtual Server 2005 Type Library
  4. From the Project menu, choose Properties and define ShowVSVersion.Class1as the start-up procedure.
  5. Enter the following sample code into Class1:

Accessing Virtual Server using Visual C++

Programs using the Virtual Server COM interface should initialize COM using the Multi-Threaded model. This requires that a call to CoInitializeEx be used instead of CoInitialize. Using the Apartment-Threaded model with the Virtual Server interface can significantly affect the Virtual Server system's performance.

Setting the COM Security level to Impersonation level is accomplished by calling CoInitializeSecurity immediately after the initial CoInitializeEx call and before any of the Virtual Server's interfaces or other COM objects are accessed.

The following console example program illustrates the steps required to initialize and access the Virtual Server COM object.

The initialization and uninitialization routines in the preceding example can easily be wrapped into a class constructor and destructor if the user's program is based on an application object.

Send comments about this topic to Microsoft

Build date: 5/1/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker