![]() |
|
#1
|
|||
|
|||
|
I prevent to use sharemem unit in my DLL file so I don't use string variable as the parameter.
Code:
function Test(const Filename:widestring;var output:widestring):boolean;stdcall; begin if Test2(Filename,output) then bla end; functon Test2(const Filename:string;var output:string):boolean; begin ; end; exports Test; Last edited by abcd; 06-28-2012 at 03:33 AM. |
|
#2
|
|||
|
|||
|
Sorry for bumping the question. Perhaps someone missed my thread.
|
|
#3
|
|||
|
|||
|
I think I have read over this post about 15 times trying to understand what it is you are asking, by "safe" are you meaning in terms of memory leaks and internal string issues? Or are you meaning something entirely different like reverse engineering, or something else I am not smart enough to comprehend? If you could provide a little more detail I think you would get some decent replies.
__________________
"not quite smart enough to be dumb" Extended Stats No Longer Available Due To Changes To The Forum.
|
|
#4
|
|||
|
|||
|
If I use a string as parameter in exported function without sharemem unit then that is "not safe" (causing access violation/memory allocation issue). That's what I mean about safe or not safe. I hope you can understand my question.
|
|
#5
|
|||
|
|||
|
It is perfectly safe to use Strings within your DLL (passing them between functions and procedures within the DLL) The memory issue only arises when you are passing strings to/from your program and a DLL.
To get around the need to include Sharemem in your program and DLL, you could use PChars, or to simplify the process, declare the values being passed as WideString. See here for an explanation: http://stackoverflow.com/a/9331077 |
|
#6
|
|||
|
|||
|
Thanks for your explanation major. Now I pass my value as WideString. Somehow sometimes I got crash and madexcept could not report the error. Probably this crash is another problem. Anyway, if I use WideString, is it safe to compile my program and DLL with different version of compiler?
|
![]() |
| Tags |
| dll |
| Thread Tools | |
| Display Modes | |
|
|