开发者

Strange string behaviour with dll call

I have a Delphi 2007 Program, which calls a Delphi 2010 DLL. The Program is big and not yet ported to 2010, so there is no way i can change this right now.

I use SimpleShareMem Unit to pass strings but also tried ShareMem with borlndmm.dll.

For one function i now pass a string from the Delphi 2007 programm to the dll (Therefore AnsiString). When debugging the dll, this AnsiString looks normal and can be viewed in the watch list. But if i do a simple think like

AnAnsiString := PassedAnsiString;

the variable AnAnsistring gets the value '???????'#0#0#0'?开发者_如何转开发??A', but PassedAnsiString is still readable in watchlist. Also a string append like

AnAnsiString := PassedAnsiString + NotPassedAnsiString;

uses '???????'#0#0#0'???A' as value.

Where is the problem? Is it a 2007 <-> 2010 issue? How to fix it? Thanks for help.


This is probably because an encoding field that was added to ansistring in D2009. IOW the record (TAnsiRec) at negative offset of the ansistring pointer is different and shifted between unicode and non unicode Delphi's (ansistring changed too in unicode versions!)

I don't think there is a decent solution for this except dropping back to p(ansi)char level

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜