Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. returning array of BSTRs from the COM component

returning array of BSTRs from the COM component

Scheduled Pinned Locked Moved COM
comdata-structures
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Raj Prathap
    wrote on last edited by
    #1

    Hi, I have a method which has to return the array of BSTRs. I'm giving the method here, please let me know if I'm doing anything wrong. HRESULT Login([in] BSTR UserName, [in] BSTR Password, int maxUsrCnt , [out]int *UsrCnt, [out, length_is(,*UsrCnt), size_is(,maxUsrCnt)] BSTR *LoggedUsers); the size of the array to be returned is not known at the time of calling. When I use this method, the first string is coming properly, but other strings are not coming. Please suggest an answer. Regards, Raja Pratap

    M 1 Reply Last reply
    0
    • R Raj Prathap

      Hi, I have a method which has to return the array of BSTRs. I'm giving the method here, please let me know if I'm doing anything wrong. HRESULT Login([in] BSTR UserName, [in] BSTR Password, int maxUsrCnt , [out]int *UsrCnt, [out, length_is(,*UsrCnt), size_is(,maxUsrCnt)] BSTR *LoggedUsers); the size of the array to be returned is not known at the time of calling. When I use this method, the first string is coming properly, but other strings are not coming. Please suggest an answer. Regards, Raja Pratap

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      I'd avoid trying to mix BSTRs and custom marshalling. Instead, I'd go with a SAFEARRAY of BSTR. To return such an array to a VB client, I'm using:

      HRESULT ExtendedHardwareType([out, retval] SAFEARRAY(BSTR)* psArray);

      Stability. What an interesting concept. -- Chris Maunder

      R 1 Reply Last reply
      0
      • M Mike Dimmick

        I'd avoid trying to mix BSTRs and custom marshalling. Instead, I'd go with a SAFEARRAY of BSTR. To return such an array to a VB client, I'm using:

        HRESULT ExtendedHardwareType([out, retval] SAFEARRAY(BSTR)* psArray);

        Stability. What an interesting concept. -- Chris Maunder

        R Offline
        R Offline
        Raj Prathap
        wrote on last edited by
        #3

        Thanks a ton Mike, working and its very easy to code.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups