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. C / C++ / MFC
  4. Returning an array of BSTR from the COM Component

Returning an array of BSTR from the COM Component

Scheduled Pinned Locked Moved C / C++ / MFC
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

    L 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

      L Offline
      L Offline
      LoveCPlusplus
      wrote on last edited by
      #2

      I never need to output the array back yet. I only guess that the last parameter should be declared as "BSTR **LoggedUsers". It is because: to output single string, should use "BSTR*". To output an array of strings, logically it should be "BSTR**". If my guess is correct, let me know. :-)

      R 1 Reply Last reply
      0
      • L LoveCPlusplus

        I never need to output the array back yet. I only guess that the last parameter should be declared as "BSTR **LoggedUsers". It is because: to output single string, should use "BSTR*". To output an array of strings, logically it should be "BSTR**". If my guess is correct, let me know. :-)

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

        I Tried with BSTR**, could not succeed. Only first string comes, since the marshaller considers only the first string, since length is not mentioned. I got a hint from one of CP members to use SAFEARRAY(BSTR)* that worked fine.

        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