SAMPLE: SAFEARAY: Use of Safe Arrays in Automation

Last reviewed: June 25, 1997
Article ID: Q131086

The information in this article applies to:

  • Microsoft OLE Libraries for Windows and Win32s, version 2.03
  • Microsoft OLE libraries included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95
    

SUMMARY

SAFEARAY is an OLE Automation server application that demonstrates the use of safe arrays.

You can find SAFEARAY.EXE (size: 42352 bytes) 
                         , a self-extracting file, on these services:

The following file is available from the Microsoft Software Library:

 ~ Safearay.exe (size: 42352 bytes) 

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TILE      : How to Obtain Microsoft Support Files from Online Services

MORE INFORMATION

SAFEARAY implements the following methods (in addition to the standard application object methods).

SlowSort: Sorts an input safearray of BSTRs and returns the sorted array and the time required for the sort. The array is passed by reference because it needs to be modified by the sort. SlowSort uses SafeArrayGetElement and SafeArrayPutElement to access the array elements.

FastSort: Has the same functionality as SlowSort but uses SafeArrayAccessData to get a pointer to the array elements. This allows array elements to be accessed directly instead of using SafeArrayGetElement and SafeArrayPutElement. This accounts for the speed improvement over SlowSort.

Average: Finds the average of an input safe array of integers. The array is not passed by reference.

GetArray: Creates and returns a safe array of BSTRs.

See the README.TXT included for instructions to compile and run this sample.


Keywords : kbfile kbprg LeTwoAt kbfile kbhowto kbprg
Version : 2.03 4.0 | 3.5 3.51
Platform : NT WINDOWS
Issue type : kbhowto
Resolution Type : kbfile


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 25, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.