|
-
November 13th, 2009, 04:02 PM
#1
How to pass strings from a dll
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 !
-
November 14th, 2009, 01:43 AM
#2
Re: How to pass strings from a dll
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?
Best regards,
Igor
-
November 14th, 2009, 06:19 AM
#3
Re: How to pass strings from a dll
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.
-
November 14th, 2009, 02:36 PM
#4
-
November 15th, 2009, 03:57 AM
#5
Re: How to pass strings from a dll
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
-
November 15th, 2009, 05:37 AM
#6
Re: How to pass strings from a dll
So that's it, all in your hands. (though I didn't get anything)
Best regards,
Igor
-
November 15th, 2009, 06:35 AM
#7
Re: How to pass strings from a dll
-
November 16th, 2009, 05:13 AM
#8
Re: How to pass strings from a dll
I am also not sure what the actual question is now.
-
November 18th, 2009, 01:40 AM
#9
Re: How to pass strings from a dll
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|