Just a sample of the Echomail archive
[ << oldest | < older | list | newer > | newest >> ]
|  Message 505  |
|  Alexander Grotewohl to Andy Gorman  |
|  Re: "Delphi" DLL  |
|  08 May 21 20:02:46  |
 TID: Mystic BBS 1.12 A47 MSGID: 1:120/616 cac7bd24 REPLY: 1:229/426.52 801c7496 TZUTC: -0400 On 08 May 2021, Andy Gorman said the following... AG> I'm creating a DLL that is going to get a value passed into it (path to a AG> file). I am able to pass in a value, but it's getting truncted in the AG> DLL. AG> AG> Here's the code: AG> AG> library SimpleLib; AG> AG> Uses AG> SysUtils; AG> AG> Var AG> Path : String; AG> o : Text; AG> AG> function MySucc(AVal : PWideString; pLen : Integer) : PWideString; AG> stdcall; begin AG> SetLength(String(AVal), pLen); AG> Assign(o, 'c:\temp\simp.txt'); AG> Rewrite(o); AG> Write(o,String(AVal)); AG> Close(o); AG> Result := AVal; AG> end; AG> AG> exports AG> MySucc; AG> End. are you calling this from C# then? it would seem SetLength() is doing something to a pointer that is not technically a 'PWideString'. (a PWideString has a known length, see https://wiki.freepascal.org/Character_and_string_types) String() on the other hand (depending on compiler settings) would force AVal to a old pascal style string where string[0] is a byte for the length. so if the length is stored in memory at str[-1] and str[0] (this is not something you'd normally interact with.. these are managed types and the compiler handles this), you're only getting one byte of the length. is there a reason you're using PWideString? SysUtils has a StrPas function that makes it fairly easy to do things like UnicodeStringVar:=StrPas(AVal); where AVal is a PWideChar .. which is usually enough for me to interact with C/C++ from pascal. sorry for the lack of code.. but i'd be unable to test it if it's called from other than pascal ;) but hopefully it's enough --- Mystic BBS v1.12 A47 2021/04/20 (Windows/32) * Origin: cold fusion - cfbbs.net - grand rapids, mi (1:120/616) SEEN-BY: 1/123 90/1 103/705 120/340 457 616 123/10 131 124/5016 129/305 SEEN-BY: 154/10 30 40 50 700 203/0 220/80 90 221/0 6 226/30 227/114 SEEN-BY: 227/201 702 229/101 424 426 550 616 664 700 1016 1017 240/5138 SEEN-BY: 240/5411 5832 5853 249/206 317 400 280/464 5003 282/1038 SEEN-BY: 292/854 8125 301/1 317/3 320/219 322/757 342/200 396/45 423/120 SEEN-BY: 712/848 770/1 2432/390 2454/119 3634/12 PATH: 120/616 154/10 280/464 240/5832 229/426 |
[ << oldest | < older | list | newer > | newest >> ]