Updated: 21 January 1999

OpenVMS Connectivity Developer Guide


Previous Contents Index

3.4 The OpenVMS MIDL Compiler

The OpenVMS MIDL compiler is identical to the Microsoft Interface Definition Language (MIDL) compiler on Windows NT 4.0 SP3 except for the following:

  1. The Microsoft MIDL implementation supports several optimization levels. The OpenVMS MIDL implementation supports only -Oicf. Do not use any other optimization level.
  2. The /cpp_cmd and /cpp_opt switches are not fully functional in the OpenVMS MIDL implementation.
  3. On a Windows NT system, Microsoft MIDL commands, switches, and qualifiers are case sensitive. The OpenVMS MIDL compiler is not case sensitive; all commands, switches, and qualifiers passed to the OpenVMS MIDL compiler are lowercase. As a result, the Microsoft MIDL switches /I and /i are equivalent on OpenVMS.
  4. MIDL-generated files are platform specific.
    You must run MIDL on both platforms. The MIDL output files generated on one platform (OpenVMS or Windows NT) cannot be copied and used on the other platform.
  5. MIDL -w switch
    The Microsoft MIDL compiler allows you to specify either -w or -warn to limit the level of warnings generated by the compiler. The OpenVMS MIDL compiler supports only the -w switch.


Chapter 4
Installing the COM for OpenVMS Kit

This chapter provides a list of the contents of the COM for OpenVMS kit, a list of prerequsite software, and a preinstallation requirements. It also describes how to install COM for OpenVMS, and includes postinstallation instructions.

4.1 Contents of the COM Version 1.0 for OpenVMS Kit

COM Version 1.0 for OpenVMS is an unauthenticated implementation---that is, COM Version 1.0 for OpenVMS makes no security checks to authenticate or validate client requests within a server. Do not use COM Version 1.0 for OpenVMS in an environment that requires secure COM. COM Version 1.1 for OpenVMS will implement NTLM authentication and will authenticate requests between a COM client and a COM server. For more information about COM for OpenVMS security, see Section 1.1.11.

The COM Version 1.0 for OpenVMS contains the following:

4.2 Prerequisites

The following software is required:

4.3 Preinstallation

Before you install COM for OpenVMS, you must configure and start TCP/IP services.

The following sections describe how to configure and start OpenVMS UCX and DIGITAL TCP/IP Services for OpenVMS.

If your system is running DIGITAL TCP/IP Services for OpenVMS, you need to read Section 4.3.1 and Section 4.3.2 only.

If your system is running OpenVMS UCX, you need to read Section 4.3.3 and Section 4.3.4 only.

4.3.1 Configuring DIGITAL TCP/IP Services for OpenVMS

If your OpenVMS system is running OpenVMS Version 7.2 and DIGITAL TCP/IP Services for OpenVMS Version 5.0, you do not need to configure DIGITAL TCP/IP Services for OpenVMS to work with OpenVMS DCE/RPC. The system automatically checks and adjusts the parameters as necessary.

4.3.2 Starting DIGITAL TCP/IP Services for OpenVMS

Use the following command to start DIGITAL TCP/IP Services for OpenVMS:


$ @SYS$STARTUP:TCPIP$STARTUP 

4.3.3 Configuring OpenVMS UCX

If your OpenVMS system is running OpenVMS Version 7.2 and OpenVMS UCX Version 4.1-12 or higher, you must configure UCX values for OpenVMS DCE/RPC. When OpenVMS DCE/RPC starts, it checks that it has the required UCX parameters. If the values are correct, OpenVMS DCE/RPC starts. If the values are not correct, OpenVMS DCE/RPC displays the command needed to fix the problem, and asks whether you want to continue OpenVMS DCE/RPC startup.

The UCX commands to set the required OpenVMS DCE/RPC parameters are as follows:


$ UCX SET PROTOCOL TCP /NODELAY 
$ UCX SET CONFIGURATION PROTOCOL TCP /NODELAY 
 
$ UCX SET PROTOCOL TCP /NOLOOPBACK 
$ UCX SET CONFIGURATION PROTOCOL TCP /NOLOOPBACK 
 
$ UCX SET COMMUNICATION/LARGE=(MAXIMUM:200) 
$ UCX SET CONFIGURATION COMMUNICATION/LARGE=(MAXIMUM:200) 
 
$ UCX SET COMMUNICATION/SMALL=(MAXIMUM:600) 
$ UCX SET CONFIGURATION COMMUNICATION/SMALL=(MAXIMUM:600) 
 
$ UCX SET COMMUNICATION /DEVICE_SOCKETS=250 
$ UCX SET CONFIGURATION COMMUNICATION/DEVICE_SOCKETS=250 

4.3.4 Starting OpenVMS UCX

Use the following command to start OpenVMS UCX Version 4.1-12 or higher:


$ @SYS$STARTUP:UCX$STARTUP

4.4 Installing COM for OpenVMS

The COM for OpenVMS installation kit contains a single POLYCENTER Software Installation file. The name of the kit is DEC-AXPVMS-DCOM-V0100--1.PCSI. You must install the COM for OpenVMS files on an OpenVMS Alpha Version 7.2 system.

To install COM for OpenVMS, invoke the POLYCENTER Software Installation utility using the following command:


 $ PRODUCT INSTALL /SOURCE=device:[user] DCOM 

For device:[user], specify the device name and directory location of the kit.

MIDL compiler license

The COM for OpenVMS MIDL compiler requires a license. Compaq provides the DCOM-MIDL PAK separately from the COM for OpenVMS kit.

Example 4-1 shows a sample installation.

Example 4-1 Sample COM for OpenVMS Installation

$ PRODUCT INSTALL /SOURCE=device:[user] DCOM 
 
The following product has been selected: 
    DEC AXPVMS DCOM V1.0                   Layered Product 
 
Do you want to continue? [YES] 
 
Configuration phase starting ... 
 
You will be asked to choose options, if any, for each selected product and for 
any products that may be installed to satisfy software dependency requirements. 
 
DEC AXPVMS DCOM V1.0 
 
    Copyright © Compaq Computer Corporation 1998. All rights reserved. 
 
Do you want the defaults for all options? [YES] 
 
    The following requirements must be met prior to installing OpenVMS DCOM 
 
      - You must be running OpenVMS Alpha V7.2 or later 
      - You must be running UCX V4.1-12 ECO2 or later 
      - You must be running OpenVMS DCE RPC 
      - In order to use the DCOM MIDL compiler you must install 
        the DCOM-MIDL License PAK 
 
    Do you want to continue? [YES] 
 
Do you want to review the options? [NO] 
 
Execution phase starting ... 
 
The following product will be installed to destination: 
    DEC AXPVMS DCOM V1.0                   DISK$COSMOS_SYS:[VMS$COMMON.] 
 
Portion done: 0%...10%...20%...30%...40%...50%...60%...80%...90%...100% 
 
The following product has been installed: 
    DEC AXPVMS DCOM V1.0                   Layered Product 
$ 

4.5 Starting COM for OpenVMS Automatically after a Reboot

Compaq recommends that you modify the SYS$MANAGER:SYLOGICALS.COM command file to control COM for OpenVMS startup.

OpenVMS Version 7.2 includes a revised SYLOGICALS.TEMPLATE file that includes new startup commands for COM for OpenVMS and related components. Review the "Coordinated Startup" section of this template file and add the appropriate information to your existing startup files.

To have COM for OpenVMS start automatically when the system boots, copy the following line to your SYLOGICALS.COM file, uncomment the line, and make sure it is set to TRUE:


$ DEFINE/SYSTEM DCOM$TO_BE_STARTED TRUE 

If you do not set COM for OpenVMS to start automatically when the system boots, you must use the following command to start COM for OpenVMS:


  $ @SYS$STARTUP:DCOM$STARTUP 

4.6 COM for OpenVMS Postinstallation Procedures

After you install the COM for OpenVMS kit, do the following:

  1. Verify that the OpenVMS Registry is running. (See Chapter 8.)
  2. Populate the OpenVMS Registry using the DCOM$SETUP utility, option 3. (See Section 5.2.)
  3. Create the DCOM$GUEST account using the DCOM$SETUP utility, option 7. (See Section 5.2.)
  4. Start COM for OpenVMS using the DCOM$SETUP utility, option 4. (See Section 5.2.)
  5. If you want COM for OpenVMS to start automatically when the system reboots, modify the $ DEFINE/SYSTEM DCOM$TO_BE_STARTED line in the SYLOGICALS.COM file. (See Section 4.5.)


Chapter 5
COM for OpenVMS Utilities for Application Development and Deployment

This chapter describes how to configure your OpenVMS system (and, optionally, your Windows NT system) to develop and deploy COM applications. It describes the following COM for OpenVMS utilities:

This chapter also includes information about configuring OpenVMS and Windows NT systems to interoperate.

Before you begin

Before you configure COM for OpenVMS on your OpenVMS system, you must install and configure required components and install COM for OpenVMS. See Chapter 4 for information about these steps.

5.1 DCOM$SETUP Utility

DCOM$SETUP is a collection of tools to help a system manager configure the COM for OpenVMS system environment. Use DCOM$SETUP to populate the OpenVMS Registry database with COM for OpenVMS keys and values.

DCOM$SETUP Conventions and Requirements

5.2 Running DCOM$SETUP

To run DCOM$SETUP, enter @SYS$STARTUP:DCOM$SETUP at the OpenVMS system prompt.

The system displays the OpenVMS COM Tools menu.

Figure 5-1 DCOM$SETUP OpenVMS COM Tools Menu



--------------------------------------------------------- 
                         OpenVMS COM Tools 
 
           1) DCOMCNFG, COM Configuration Properties 
           2) GUIDGEN, Globally Unique Identifier Generator 
           3) Populate the Registry database for COM 
           4) Start the COM server 
           5) Stop the COM server 
           6) Register a COM application 
           7) Create the DCOM$GUEST account and directory 
 
           H) Help 
           E) Exit 
 
Please enter your choice: 
--------------------------------------------------------- 

To choose an option, enter the option number. The options are as follows:

5.2.1 Starting and Stopping the COM Server (DCOM$RPCSS Process)

COM for OpenVMS requires that the COM server process (DCOM$RPCSS) always be running. The DCOM$RPCSS process on OpenVMS provides the same functions for the COM run-time environment that the RPCSS process provides on Microsoft Windows NT, including the following:

To start DCOM$RPCSS, either use DCOM$SETUP option 4 ("Start") (see Section 5.2) or call the COM for OpenVMS startup procedure directly from SYS$STARTUP:DCOM$STARTUP.

To stop DCOM$RPCSS on your system, either use the DCOM$SETUP option 5 ("Stop") (see Section 5.2) or call the COM for OpenVMS shutdown procedure directly from SYS$STARTUP:DCOM$SHUTDOWN.

5.2.2 Registering an Application

The following example shows how to register the COM for OpenVMS "Simple" application included on the COM for OpenVMS kit. You can use the resulting Windows NT file to register the server on a Windows NT system as long as the application is available on your Windows NT system.

To build the "Simple" application on a Windows NT system, see and execute the instructions in the README-SIMPLE.TXT file in DCOM$EXAMPLES:[SIMPLE].

Note

You must build and compile the application before you can register it. For complete details, see the step-by-step example in [SYSHLP.EXAMPLES.DCOM.SIMPLE], included in the COM for OpenVMS kit.

Use the following procedure:

  1. From the DCOM$SETUP menu, enter 6 or REGISTER.
  2. Answer the questions as follows:

    Note

    The "Simple" application already has a CLSID.

    Example 5-1 Sample" Simple" Application Registration on OpenVMS

    Enter server type (1. In-Proc  2. Out-Proc): 2 [Return] 
    Enter Local Path (device:[directory]filename.ext): USER:[SMITH]SSERVER.EXE [Return] 
    Enter Application Name (<RETURN> to assign default): COM Simple Server [Return] 
    Does the server have a CLSid {GUID} (Yes/No) [N]: Y [Return] 
    Enter the CLSid (i.e. {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}: 
       {5e9ddec7-5767-11cf-beab-00aa006c3606} [Return] 
     
    Verify Application Information: 
     
             Application Name: COM SIMPLE SERVER 
             Local Path: USER:[SMITH]SSERVER.EXE 
             Application ID: {5E9DDEC7-5767-11CF-BEAB-00AA006C3606} 
     
    Is the information correct (Yes/No) [Y]: [Return] 
    Register application (Yes/No)? [Y]: [Return] 
     
    SETUP-I-NEWFILES, The following files have been created: 
     
          USER:[SMITH]SSERVER.REG_NT 
          USER:[SMITH]SSERVER.REG_VMS 
     
    SETUP-I-SRVIN, Server has been registered 
    Press RETURN to continue: [Return] 
    

To register the "Simple" application on a Windows NT system, use the following procedure:

  1. Copy all the files in the [SYSHELP.EXAMPLES.DCOM.SIMPLE] directory to your Windows NT system.
  2. Rename SSERVER.REG_NT to SSERVER.REG.
  3. Edit the file to point to the local server path.
    For example, replace DEVICE:\SSERVER with C:\SSERVER.
  4. Run the Install.bat program to add the necessary keys to the Windows NT registry.

Example 5-2 shows the contents of SSERVER.REG_NT.

Example 5-2 Contents of SSERVER.REG_NT

REGEDIT 
HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606}\ = DCOM server application SSERVER 
HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606}\LaunchPermission = Y 
HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606}\LocalServer32 = DEVICE:\SSERVER 

To reregister the "Simple" application on an OpenVMS system, enter the following command at the system prompt:


$ @SSERVER.REG_VMS

Example 5-3 shows the contents of the SSERVER.REG_VMS command procedure:

Example 5-3 Contents of SSERVER.REG_VMS

$ Set noon 
$ regcp :=  $regcp 
$ crekey := $regcp create key 
$ creval := $regcp create value 
$ modval := $regcp modify value 
$ lisval := $regcp list value 
$ crekey HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606} 
$ creval HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606} - 
              /data="DCOM server application SSERVER" /type=sz 
$ creval HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606} /name="AppID" - 
              /data="{5E9DDEC7-5767-11CF-BEAB-00AA006C3606}" /type=sz 
$ crekey HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606}\LaunchPermission 
$ creval HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606}\LaunchPermission - 
              /data="Y" /type=sz 
$ crekey HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606}\LocalServer32 
$ creval HKEY_CLASSES_ROOT\CLSID\{5E9DDEC7-5767-11CF-BEAB-00AA006C3606}\LocalServer32 - 
              /data="USER::[SMITH]SSERVER.EXE" /type=sz 
$ 

5.3 Running DCOM$CNFG

DCOM$CNFG is a utility to help COM developers configure and manage COM for OpenVMS applications on OpenVMS. Use the DCOM$CNFG utility to query information and manipulate properties of COM for OpenVMS applications.

To use the DCOM$CNFG utility, from the DCOM$SETUP menu, choose option 1.

Note

You must have OpenVMS Registry Read access to read application properties, and Write access to modify application properties.

The system displays the DCOM$CNFG Main menu.

Figure 5-2 DCOM$CNFG Main Menu



--------------------------------------------------------- 
                DCOM$CNFG Main 
 
        1 - Applications List 
        2 - System-wide Default Properties 
        3 - System-wide Default Security 
 
 
        (E to Exit) 
        (H for Help) 
 
        Enter <CTRL-Z> or 'E' to return to the previous menu at any time 
 
        Please enter your choice: 
--------------------------------------------------------- 

The options are as follows:

5.3.1 The DCOM$CNFG Application List Submenu

To display this submenu, from the DCOM$CNFG Main menu, choose option 1. The system displays the Applications List submenu.

Figure 5-3 Applications List Submenu



--------------------------------------------------------- 
                Applications List 
 
        Index    Name 
          1      Inside COM, Chapter 11 Example 
          2      application 2
          3      application 3
          .      ... 
          .      ... 
          .      ... 
 
        (E to Exit to previous menu) 
        (H for Help) 
 
        Please enter Index number to select an Application: 
--------------------------------------------------------- 

Enter a number to select an application. You can then view or configure its properties.

This option displays the Application Properties submenu.

Figure 5-4 Application Properties Submenu



------------------------------------------------------------------ 
               Application Properties 
 
        General Properties of this DCOM Application 
 
        Application name:  Inside COM, Chapter 11 Example 
        Application id:    {0C092C2C-882C-11CF-A6BB-0080C7B2D682} 
        Application type:  local server 
        Local path:        DISK1:[SMITH.DISPATCH_SAMPLE1]CMPNT.EXE 
        Type Library:      {D3011EE1-B997-11CF-A6BB-0080C7B2D682} 
          version: 1.0  DISK1:[SMITH.DISPATCH_SAMPLE1]Server.tlb 
 
        1 - Location    Machine to run application 
        2 - Security    Security permissions for application 
        3 - Identity    User account to use to run application 
 
        (E to Exit to previous menu) 
        (H for Help) 
 
        Please enter Application Property you wish to change: 
------------------------------------------------------------------ 

If the system cannot find the type library file or if the type library is unaccessible, the system displays an error message next to the type library file name.

The options are as follows:

5.3.2 The DCOM$CNFG System-wide Default Properties Submenu

To display this submenu, from the DCOM$CNFG Main menu, choose option 2. The system displays the System-wide Default Properties submenu:

Figure 5-7 System-wide Default Properties Submenu



--------------------------------------------------------- 
                System-wide Default Properties 
 
        1 - Enable Distributed COM on this computer (Yes/No) 
                 Current value: Yes 
        2 - Default Authentication Level 
        3 - Default Impersonation Level 
        4 - Provide additional security for reference tracking (Yes/No) 
 
 
        (E to Exit to previous menu) 
        (H for Help) 
 
        Please enter your choice: 
--------------------------------------------------------- 

The options are as follows:

5.4 Configuring Windows NT and OpenVMS Systems to Interoperate

Caution

COM Version 1.0 for OpenVMS does not support security on COM objects, including activation security. For COM objects to interoperate correctly between OpenVMS systems and Windows NT, you must configure these objects to run without security enabled.

Before any COM applications can interoperate with Windows NT and OpenVMS, you must set certain values in the Windows NT Registry and in the OpenVMS Registry.

5.4.1 Configuring the OpenVMS System

The DCOM$SETUP utility sets the OpenVMS Registry values by default when you choose the POPULATE option (see Section 5.2).

5.4.2 Configuring the Windows NT System

On Windows NT systems, you must set the Windows NT Registry values by using the Windows NT Registry editor. To set the Windows NT Registry values, use the following procedure:

  1. Start the Windows NT Registry editor.
  2. Select the following registry key:


    HKEY_LOCAL_MACHINE\Software\Microsoft\Ole 
    

  3. Add or modify the following values:
    Value name Value Registry type
    ActivationSecurity N REG_SZ
    PersonalClasses N REG_SZ
    LegacyAuthenticationLevel 1 REG_DWORD
    LegacyImpersonationLevel 3 REG_DWORD
  4. You must reboot the Windows NT system for these changes to take effect.

5.4.3 Configuring an Application on Windows NT

Before you can run a COM application on Windows NT, you must register the application's CLSID (see Section 5.2) and set its security properties.

Registering the Application

For simple applications developed on OpenVMS, go to the DCOM$SETUP Main menu, and choose option 6 (Register a COM application) (see Section 5.2). This option creates an OpenVMS command procedure that registers the component on OpenVMS. It also creates a Windows NT Registry file that you can copy to a Windows NT system and run with the Windows NT Registry editor.

For applications whose registration process is more complex, see Section 6.6.

Setting the Security Properties

After you register the component, check the security properties on that component to ensure that an unauthenticated user can activate the image. To do this, run DCOMCNFG on the Windows NT system, select the object by name, click the Properties... button, then click the Security tab.

After you set security properties, you must set the identity of the account to run the application.

To do this, click the Identity tab, then click the button next to The interactive user.

5.5 Registering In-Process Servers: DCOM$REGSVR32 Utility

All COM components (implemented as either an out-of-process server or as an in-process server) must be registered in the OpenVMS Registry before you can use them.

Out-of-process servers, which are implemented as executable programs (.EXE files), usually contain code to register and unregister the components contained within them. The advantage an out-of-process server has over an in-process server is that you can run the executable and automatically create the necessary registry keys.

In-process servers, which are usually implemented as dynamic link libraries (DLL files) on Windows NT or as shareable images on OpenVMS, also contain code to register and unregister the components within them automatically. However, these in-process servers cannot be run the same way as an executable image because they do not contain a main entry point. As a result, you must manually register the components contained within a .DLL, or create a command procedure to perform the registration.

Microsoft provides the REGSVR32 utility that you can use to register the components contained within a DLL. REGSVR32 takes as a command line argument the following:

When registering a DLL's components, REGSVR32 searches the specified DLL for the DllRegisterServer symbol and, if found, calls it. When unregistering a DLL, REGSVR32 calls DllUnregisterServer. This means that all in-process components that you want to register automatically must include these two entry points in their export files.

To facilitate the registration of components contained within shareable images on OpenVMS systems, Compaq created the DCOM$REGSVR32 utility. DCOM$REGSVR32 does the same things that the Microsoft REGSVR32 utility does. Any shareable images that contain components to be registered must also include the DllRegisterServer and DllUnregisterServer universal symbols in their symbol vectors. Both the DCOM$REGSVR32 and the REGSVR32 utilities use the same command line syntax.

During the COM for OpenVMS installation, the system places the DCOM$REGSVR32.EXE file in the SYS$SYSTEM directory.

Before you use the DCOM$REGSVR32 utility, you must define a symbol that allows the utility to accept foreign command lines. For example:


$ regsvr32 :== $DCOM$REGSVR32 

Alternatively, you can activate the DCOM$REGSVR32 utility as follows:


$ MCR DCOM$REGSVR32 

You can use either method to activate the utility, and register or unregister components contained in shareable images.

To display help for DCOM$REGSVR32, enter the following:


$ regsvr32 -? 

Table 5-1 summarizes the DCOM$REGSVR32 command line options.

Table 5-1 DCOM$REGSVR32 Command Line Options
Switch Use
-?, /? Display help file (this table).
shareable-image-name Register the specified shareable image name.
-u or /u image-name Unregister the specified shareable image name.

Note

DCOM$REGSVR32 requires that the shareable image name contain a full directory specification.

Example 5-4 demonstrates registering an in-process component (contained within a shareable image) using the DCOM$REGSVR32 utility.

Example 5-4 Registering a Component Using the DCOM$REGSVR32 Utility

$ regsvr32 USER$DISK:[SEYMOUR.DISPATCH_SAMPLE1]CMPNT$SHR.EXE 
Class factory:          Create self. 
DllRegisterServer:      Registering Server DLL 
Creating key CLSID\{0C092C2C-882C-11CF-A6BB-0080C7B2D682} 
Creating key CLSID\{0C092C2C-882C-11CF-A6BB-0080C7B2D682}\InProcServer32 
Creating key CLSID\{0C092C2C-882C-11CF-A6BB-0080C7B2D682}\ProgID 
Creating key 
CLSID\{0C092C2C-882C-11CF-A6BB-0080C7B2D682}\VersionIndependentProgID 
Creating key CLSID\{0C092C2C-882C-11CF-A6BB-0080C7B2D682}\TypeLib 
Creating key InsideCOM.Chap11 
Creating key InsideCOM.Chap11\CLSID 
Creating key InsideCOM.Chap11\CurVer 
Creating key InsideCOM.Chap11.1 
Creating key InsideCOM.Chap11.1\CLSID 
Class factory:          Destroy self. 

Example 5-5 demonstrates unregistering an in-process component (contained within a shareable image) using the DCOM$REGSVR32 utility.

Example 5-5 Unregistering a Component Using the DCOM$REGSVR32 Utility

$ regsvr32 /u USER$DISK:[SEYMOUR.DISPATCH_SAMPLE1]CMPNT$SHR.EXE 
 
Class factory:          Create self. 
DllUnregisterServer:    Unregistering Server DLL 
Deleting key InProcServer32 
Deleting key ProgID 
Deleting key VersionIndependentProgID 
Deleting key TypeLib 
Deleting key LocalServer32 
Deleting key CLSID\{0C092C2C-882C-11CF-A6BB-0080C7B2D682} 
Deleting key CLSID 
Deleting key CurVer 
Deleting key InsideCOM.Chap11 
Deleting key CLSID 
Deleting key InsideCOM.Chap11.1 
Class factory:          Destroy self. 


Chapter 6
Developing a COM for OpenVMS Application

This chapter explains how to develop COM applications for OpenVMS.

Note

You can find the sample COM applications shown in this chapter in the following directories on the COM for OpenVMS kit:


DCOM$EXAMPLES:[SAMPLE1] 
DCOM$EXAMPLES:[SIMPLE] 
DCOM$EXAMPLES:[DISPATCH_SAMPLE1] 

SAMPLE1 and DISPATCH_SAMPLE1 are taken from Dale Rogerson's book, Inside COM, published by Microsoft Press. This book is a good reference for developing COM applications.

6.1 Creating a COM Application

The following sections describe how to create a COM for OpenVMS application.

Note

Building COM for OpenVMS applications places demands on the virtual memory requirements of a process. You should have a minimum page file quota of 100,000 pagelets before building a COM for OpenVMS application. This is a DEC C++ compiler requirement.

6.2 Step 1: Generate Unique Identifiers

Use the DCOM$GUIDGEN utility to generate 16-byte globally unique identifiers (GUIDs). The utility supports both OpenVMS and UNIX styles. For example:

The following table summarizes the GUID format options.
OpenVMS qualifier (value) UNIX switch Use
IDL -i Output GUID in an IDL interface template.
STRUCT -s Output GUID as an initialized C struct.
IMPLEMENT_OLECREATE -c Output GUID in IMPLEMENT_OLECREATE(...) format.
DEFINE_GUID -d Output GUID in DEFINE_GUID(...) format.
GUID_STRUCT -g Output GUID as an initialized static const GUID struct.
REGISTRY_GUID -r Output GUID in registry format.

Note

The last four options in the preceding table are the same as the four options in the Windows NT Guidgen utility.

The following table lists additional options supported by the DCOM$GUIDGEN utility.
OpenVMS qualifier UNIX switch Use
/OUTPUT= filename -o filename Redirect output to a specified file.
/COUNT= number -n number Number of GUIDs to generate.
not available -h, -? Display command option summary.

You can specify more than one format for the same GUID.

6.3 Step 2: Build an Application Using the MIDL Compiler

The following sections describe how to use the MIDL compiler to build an application.

6.3.1 Running the MIDL Compiler

The MIDL compiler consists of the following separate images:

To run MIDL, you must first define a DCL symbol. For example:


    $ midl :== $dcom$midl 
    $ midl -? 
    $ midl -Oicf -idcom$library: example.idl 

The midl -? command displays a list of valid command line arguments. For a list of these arguments, see Appendix A.

6.3.2 Running the MIDL Compiler with DCOM$RUNSHRLIB

The DCOM$MIDL.EXE utility gets its arguments from the DCL foreign command line buffer. DCL foreign commands can have a maximum of 255 characters.

Because of the number of arguments that DCOM$MIDL.EXE can accept, you might exceed this maximum number of characters if you specify a complex MIDL command (for example, a command that contains mixed-case arguments that require quotation marks).

As a workaround, you can use the SYS$SYSTEM:DCOM$RUNSHRLIB.EXE utility. Use the following procedure:

  1. Define the DCL command DCOM$RUNSHRLIB.
    A process that needs to use DCOM$RUNSHRLIB.EXE must first use the OpenVMS DCL Command Definition utility to define the DCL command DCOM$RUNSHRLIB. For example:


      $ SET COMMAND DCOM$LIBRARY:DCOM$RUNSHRLIB.CLD 
    

    DCOM$LIBRARY:DCOM$RUNSHRLIB.CLD defines the DCOM$RUNSHRLIB DCL command. The following table shows the command's parameters.
    Argument Value Required/Optional
    P1 Name of the shareable image library. This can be a logical name, the name of an image in SYS$SHARE:, or a full file specification. Required
    P2 Name of the routine to be called as a C or C++ main() routine with an argc/argv vector. Required
    P3 List of qualifiers in quotation marks. Optional

  2. Define the DCL symbol midl to use DCOM$RUNSHRLIB.EXE to parse the command line and call the DCOM$MIDL_MAIN function in the DCOM$MIDL_SHR shareable image library. For example:


      $ midl :== DCOM$RUNSHRLIB DCOM$MIDL_SHR DCOM$MIDL_MAIN 
    

    The new DCL command MIDL accepts multiple command line arguments inside a single quoted string. If the command becomes too long, you can specify multiple quoted strings, using a comma to separate the strings.
    For example, here is a complex MIDL command that fails:


      $ midl :== $dcom$midl 
      $ midl -Zp8 -Oicf -Os -oldnames -char unsigned - 
         -error allocation -error bounds_check -error stub_data - 
         -ms_ext -c_ext -out [.OBJ] - 
         -I[INC] -I[PROJECT_WIDE_INC] -I[COMMON_INC] -IDCOM$LIBRARY: - 
         -DRMS_DB "-DOpenVMS_Definitions" "-DPermanentProcess" - 
         -header [.obj]example.h -client none -server none example.idl 
      %DCL-W-TKNOVF, command element is too long - shorten 
    

    You can successfully specify this command using DCOM$RUNSHRLIB as follows:


      $ set command dcom$library:dcom$runshrlib.cld 
      $ midl :== DCOM$RUNSHRLIB DCOM$MIDL_SHR DCOM$MIDL_MAIN 
      $ midl "-Zp8 -Oicf -Os -oldnames -char unsigned",- 
         "-error allocation -error bounds_check -error stub_data",- 
         "-ms_ext -c_ext -out [.OBJ]",- 
         "-I[INC] -I[PROJECT_WIDE_INC] -I[COMMON_INC] -IDCOM$LIBRARY:",- 
         "-DRMS_DB -DOpenVMS_Definitions -DPermanentProcess",- 
         "-header [.obj]example.h -client none -server none example.idl" 
    

6.3.3 Required MIDL Switches

When running MIDL on OpenVMS, you must specify the -Oicf MIDL command line switch.

6.3.4 Required Include Directories

MIDL components typically import UNKNWN.IDL, which contains the component definitions for IUnknown and IClassFactory. UNKNWN.IDL and other COM-related IDL and header files are located in DCOM$LIBRARY. To build your component's IDL file, use the following switch:


-IDCOM$LIBRARY: 

6.3.5 Required Header File

The VMS_DCOM.H header file contains macro definitions that enable your COM for OpenVMS application to compile properly with Bristol's Wind/U® Win32 environment. You must include this header file in every source file and header file you create that relies on COM APIs or Win32 APIs. Because the files generated by MIDL rely on parts of the Win32 environment, Compaq has modified the MIDL compiler for OpenVMS to include VMS_DCOM.H in all output files.

Note to COM for OpenVMS EFT1 users

If you included references to VMS_DCOM.H in your IDL source files, you can remove the IDL cpp_quote() directives. That is, if you added the following code to your source files for COM for OpenVMS EFT1, you can delete it:


cpp_quote("#if defined(__vms)") 
cpp_quote("#include <VMS_DCOM.H>" 
cpp_quote("#endif // defined(__vms)") 

6.4 Step 3: Compile the COM Application

The following sections describe how to compile COM for OpenVMS applications.

Note

When you develop COM applications that require Read access to the OpenVMS Registry, you must be sure that you have the REG$LOOKUP identifier. For applications that require Read and Write access to the OpenVMS Registry (either during development or at run time), you must have either the REG$UPDATE identifier or the SYSPRV privilege. For more information about OpenVMS Registry privileges, see Section 7.5.1.

6.4.1 Required Macro Definitions

The VMS_DCOM.H file defines several macros used by the Wind/U Win32 environment. An include statement that specifies this header file should be the first noncommented line in any source file (code or header files) that you write. However, this is not always guaranteed to be true for files generated by MIDL. Be sure to always include the following /DEFINE qualifier on all of your C and CXX commands:


 /DEFINE=(UNICODE=1,_WINDU_SOURCE=0X041000,_WIN32_DCOM) 

The UNICODE macro ensures that the wide character variants of Win32 APIs and data structures are enabled when you compile your code. (This macro is also defined in VMS_DCOM.H.) Omitting this macro can lead to compilation failures when building with the Wind/U Win32 environment.

The other two macro definitions are recognized by the Wind/U header files and are required to ensure the proper definition of structures and COM APIs.

6.4.2 Required Include Directories

COM for OpenVMS applications typically require header files that come from DCOM$LIBRARY.

Include the following qualifier on your C and CXX command lines:


 /INCLUDE=DCOM$LIBRARY 

If you already have an /INCLUDE qualifier on your command line, modify the command to include DCOM$LIBRARY.

6.4.3 Required Header File: VMS_DCOM.H

The VMS_DCOM.H header file defines several macros used by the Wind/U header files.

Include this header file as the first noncommented line in your source files (both header files and implementation files).

6.4.4 Required C++ Qualifiers


Previous Next Contents Index

Copyright © Compaq Computer Corporation 1999. All rights reserved.

6539P001.HTM