I am new to DLL writing
I can return numbers from a DLL but seem unable to return strings.
Anyone know how to do this in a DLL ?
Thanks in advance !
Printable View
I am new to DLL writing
I can return numbers from a DLL but seem unable to return strings.
Anyone know how to do this in a DLL ?
Thanks in advance !
Dll is a library, just a bunch of functions. Can you return strings from functions? If yes, you can return strings from dll.
BTW, string is the most ambiguous thing in C++. What kind of strings you imply?
I want to return
Either char or a pointer to string.
Its for use in a basic compiler called Liberty Basic you might have heard of it or not
I have written DLLs that return numbers for liberty basic but cant seem to get my head around strings at all.
I think you have to allocate memory for it first but i am not sure the books i have on writing dll's are not that clear when it comes to this.
They are very clear when returning numbers.
I will read up on returning strings from functions.
Any further help will be greatly appreciated.
Okay man, now it turns out that you need to return Basic strings. :D
So let me ask you a few questions. Do you completely understand that these languages may (or better say, must) have different concepts of strings and therefore different implementations of string object? Do you completely understand, that trying to return Basic string from C code you need to know the low-level details of how Basic string should look like in memory? And now, do you know those details? Or do you have an idea of how/where to find them? :) Or returning pointer to C string, are you sure the Basic is able to understand it? :)
BTW, your real situation has no connection to dll stuff.
Yes I understand that this Language handles strings in a non C++ way.
The Basic copies the string in memory then adds a null terminator (An ASCII ZERO)
This technique provides a copy of the original string to be passed to the dLL function. If the function then modifies that string directly , then the Liberty BASIC application calling the function cannot access the modified string because only the copy is modified.
The way to fix this is for the code to include the ASCII zero onto the end of the string that will be used as a parameter in the API call. Liberty BASIC checks for the ASCII zero, and if it finds it, passes the memory address of original string and does not make a copy. This is only necessary if an application passes a string, expecting to get it back modified by the DLL function called.
Thanks
:) So that's it, all in your hands. (though I didn't get anything)
OK thanks anyway
I am also not sure what the actual question is now. :confused: :)
I have resolved all issues with this.
As Igor said the issue was not with the dlll
it was with the basic.
Once I got my head around that I was able to get it to work.
Thanks again Igor.