<p>I am a COM object written in ATL that is used from a C++ application, and I want to pass an array of BYTEs between the two.  My experience of COM/IDL so far is limited to passing simple types (BSTRs, LONGs, etc.).</p>

<p>Is there a relatively easy way to have the COM object pass an array to the caller?  For example, I want to pass a raw image (TIFF) instead of messing with temporary files.</p>

Check out using
safearrays
. Here's some example code:
The safearray is returned as a pointer to a VARIANT
```
```
[id(1), helpstring("LogCache")] HRESULT LogCache([out,retval] VARIANT* logCache);
```
```
Safearrays are pretty easy to use. Here's some example code which is a cache of the latest 1000 log messages of some application:
```
```
safearray_t<bstr_t> m_logCache;
   ...
   if (m_logCache.size() > 1000)
   {
       m_logCache.pop_back();
   }

   m_logCache.push_front(Msg.str(), 0);

    variant_t LogCache()
    {
        if (!m_logCache.is_empty())
        {
            variant_t cache(m_logCache);
            return cache;
        }
    }
```
```
Note that the syntax in your case is almost certainly going to be different since I'm using the
comet COM library
, but the ideas/concepts are the same.