CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Safearray

  1. #1
    Join Date
    Sep 2003
    Posts
    815

    Safearray

    Hello,

    I was wondering how do I create a SAFEARRAY that holds a non trivial type like a strcut I define?

    Thanks
    Avi

  2. #2
    Join Date
    Mar 2004
    Location
    Israel
    Posts
    638
    Wrap std::vector as member in a new class, and implement 2 versions
    for operator[] (for const and non-const accesses) with safety bounds checks.
    provide any interface you need such as insert,reserve and so.

    Regards,
    Guy
    **** **** **** **** **/**

  3. #3
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    Based on his previous posts, I believe that the mentioned SAFEARRAY is from MS COM.

  4. #4
    Join Date
    Sep 2003
    Posts
    815
    Quote Originally Posted by Kheun
    Based on his previous posts, I believe that the mentioned SAFEARRAY is from MS COM.
    yep, anyway I find out how to do that (in some other post):

    SAFEARRAY * psa;
    SAFEARRAYBOUND rgsabound[1];

    rgsabound[0].lLbound = 0;
    rgsabound[0].cElements = 0;

    psa = SafeArrayCreate(VT_RECORD, 1, rgsabound);


    what I still don't know how to do is the connection points/callback/events (my other thread)
    Any chance you know?

    Thanks
    Avi

  5. #5
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    I did that about 2 years ago and unfortunately I couldn't recall the details now. Anyway, I managed to do that based on Chapter 8 in the book, The COM and COM+ Programming Primer by Alan Gordon.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured