SafeArray Sample

This sample is located in \Samples\Com\SafeArray.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

A safe array is an array that contains information about the number of dimensions and the bounds of its dimensions.

This sample displays a DLL registry message box and the contents of a safe array.

Using the Sample

To run the sample

  1. Ensure that Microsoft® Visual Basic® 5.0 or later is installed.

  2. Ensure that the runtime DLL MSVBVM50.dll or later is in the system path.

  3. From the command line, change to the \Samples\Com\SafeArray directory and type:

    nmake

  4. From the command line, change to the \Samples\Com\SafeArray directory and type:

    run

    A message box displays the following message:

    DLLRegisterServer in SimpleObject.dll succeeded.
    
  5. Click OK to clear the message box and display the following output in the console window:
    ComputeSum() returned 10 
    CreateSquares() returned { 0 1 4 9 16 25 36 49 64 81 100 } 
    Converting results to Java array: { 0 1 4 9 16 25 36 49 64 81 100 } 
    

To uninstall the sample

In the \Samples\Com\SafeArray directory, type:

remove

Key Project Files

run.java

This file's main method instantiates a COM object, passes a SafeArray to that object, receives the SafeArray back from the COM object, and extracts SafeArray elements one at a time or translates the entire SafeArray to a Java array.

Technologies Demonstrated

J/Direct, COM

This sample shows how to:

© 1999 Microsoft Corporation. All rights reserved. Terms of use.