Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Returning a string from VC++ dll to VB

  • 26-02-2006 11:23am
    #1
    Registered Users, Registered Users 2 Posts: 250 ✭✭


    I have seen a few "examples" on the web for returning a string from a dll written in VC++ to VB, in particular an article written by Nick Skapura (posted on various VB sites).

    My problem is that this article (which has very good working example of passing parameters between VB and C++ in general) does not cover passing a newly created string back to VB, but uses a memory address already allocated to a parameter passed into the dll function at the initial call, to return the string to vb.

    Does anybody know of a good tutorial that will explain how to do this? Also, some tutorials talk abt using BSTR to return a string-like structure for VB to work with, and other tutorials talk abt only passing passing back the pointer address. Which is better for safe and stable VB-C++ communication (taking into consideration coding efforts to make each scenario work)

    TIA


Comments

  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    Why do you want to return a newly created string? Why not follow the method in the article where it sends a pointer to the string location? Many Windows API functions use this form.


  • Registered Users, Registered Users 2 Posts: 250 ✭✭ikoonman


    daymobrew wrote:
    Why do you want to return a newly created string? Why not follow the method in the article where it sends a pointer to the string location? Many Windows API functions use this form.

    That would be ideal, but I haven't really seen any examples/tutorials where it returns pointer-to-string for use in VB. Do you perhaps have any links?

    TIA


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    ikoonman wrote:
    That would be ideal, but I haven't really seen any examples/tutorials where it returns pointer-to-string for use in VB. Do you perhaps have any links?

    TIA
    ikoonman wrote:
    but uses a memory address already allocated to a parameter passed into the dll function at the initial call, to return the string to vb.
    pointer == memory address.
    I meant use Nick Skapura's example you found. It's a solution that works. Why don't you want to use that form?


  • Registered Users, Registered Users 2 Posts: 250 ✭✭ikoonman


    daymobrew wrote:
    pointer == memory address.
    I meant use Nick Skapura's example you found. It's a solution that works. Why don't you want to use that form?

    I understand that yes, but then I read up on Google Groups and a lot of people were complaining that you could only use the length of the buffer as passed in by the VB app - so i assume that meant that if the var declared in VB was STRING * 100, you pretty much had a buffer of 100 bytes for the C dll to populate and return. I want more than that (to a max of say 1 meg)


  • Closed Accounts Posts: 3,357 ✭✭✭Beano


    I havent read the article you mention but a string in VB is either fixed length or variable length. If the article mentions variable length strings then you have no problem as their max size is approx 2 billion characters. If it uses fixed length strings then you're out of luck as they have a max of 64K characters.


  • Advertisement
Advertisement