Passing Arrays in COM


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: Passing Arrays in COM

  1. #1
    Join Date
    May 2005
    Posts
    5

    Passing Arrays in COM

    Need help with passing a BYTE array in COM.

    I think i have done it right but i only get the first byte passed.

    Here is the idl:

    interface ICOMtestObject : IUnknown
    {
    [id(1), helpstring("method GetData")] HRESULT GetData([out]ULONG *sz,[out,size_is(,*sz)]BYTE **data);
    };

    Here is the implementation in the COM server:

    STDMETHODIMP CCOMtestObject::GetData(ULONG *sz, BYTE **data)
    {
    // TODO: Add your implementation code here

    *data = (BYTE*)CoTaskMemAlloc( 5 * sizeof( BYTE));

    (*data)[0]='T';
    (*data)[1]='e';
    (*data)[2]='s';
    (*data)[3]='t';
    (*data)[4]='\0';
    *sz=5;
    return S_OK;
    }

    Here is the implementation in the client:

    HRESULT hr = m_objPtr.CoCreateInstance(L"Comtest.COMtestObject.1");

    ULONG sz;BYTE *data;
    hr = m_objPtr->GetData(&sz,&data);

    The data array includes only the first byte.

    Please help me with this one.
    Attached Files Attached Files

Similar Threads

  1. Replies: 0
    Last Post: 10-16-2002, 03:48 PM
  2. Passing arrays to Oracle stored procedure
    By NJMrbig in forum VB Classic
    Replies: 0
    Last Post: 01-16-2002, 10:07 AM
  3. Replies: 2
    Last Post: 10-11-2001, 01:46 AM
  4. Replies: 1
    Last Post: 08-06-2001, 12:04 PM
  5. Passing Arrays
    By Balaji in forum VB Classic
    Replies: 0
    Last Post: 04-04-2000, 03:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center