I'm creating a DLL that is going to get a value passed into it (path to a file). I am able to pass in a value, but it's getting truncted in the DLL.
Here's the code:
library SimpleLib;
Uses
SysUtils;
Var
Path : String;
o : Text;
function MySucc(AVal : PWideString; pLen : Integer) : PWideString; stdcall; begin
SetLength(String(AVal), pLen);
Assign(o, 'c:\temp\simp.txt');
Rewrite(o);
Write(o,String(AVal));
Close(o);
Result := AVal;
end;
exports
MySucc;
End.
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.
are you calling this from C# then? it would seem SetLength() is doing
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 368 |
Nodes: | 16 (2 / 14) |
Uptime: | 87:13:03 |
Calls: | 7,895 |
Calls today: | 1 |
Files: | 12,968 |
Messages: | 5,792,154 |