SAMPLE: SAFEARAY: Use of Safe Arrays in Automation

ID: Q131086

The information in this article applies to:

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 
Version           : 2.03 4.0 | 3.5 3.51
Platform          : NT WINDOWS
Issue type        : kbhowto

Last Reviewed: June 26, 1997