SAMPLE: SndArray.exe Sends/Receives Variant Arrays from/to MSMQ

ID: Q199165


The information in this article applies to:


SUMMARY

The SndArray.exe sample demonstrates how to convert an array of variants to a byte array and send and receive it in an MSMQ message.


MORE INFORMATION

The following file is available for download from the Microsoft Software Library:

SndArray.exe

Release Date: Jan-21-1999

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services

The SndArray.exe sample demonstrates how to convert an array of variants to a byte array and send and receive it as an MSMQ message.

The Visual Basic sample uses two helper functions (GetVariantArrayFromBuffer and GetBufferFromVariantArray) implemented in a Win32 DLL created by a Visual C++ 5.0 project. Both Visual C++ and Visual Basic samples are included in the self-extracting file.

To send an array of variants as an MSMQ message, you need to manually serialize your array of variants to a byte array and unpack it at the receiver. The sample code does this generically for an array of Variants whose fields are numeric or strings. You can implement more complex types in a similar manner by modifying the source code of this sample. You can also use the Variant array support to simulate structures by sending over the field names.



Uncompress the SndArray.exe file and build the Visual C++ sample to create the DLL. Change the lib path appropriately for the following statements in the Visual Basic application:


Private Declare Function GetBufferFromVariantArray Lib "c:\temp\SendArray\debug\SendArray.dll" ( _
    pvarIn As Variant, _
    pcbBuf As Long, _
    pvarOut As Variant) As Long
Private Declare Function GetVariantArrayFromBuffer Lib "c:\temp\SendArray\debug\SendArray.dll" ( _
    ByVal cbBuf As Long, _
    pvarIn As Variant, _
    pvarOut As Variant) As Long 


Additional query words:


Keywords          : kbfile kbsample kbMSMQ100 
Version           : winnt:1.0
Platform          : winnt 
Issue type        : 

Last Reviewed: January 22, 1999