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: | deepend |
|---|---|
| Location: | Calgary, Alberta |
| Users: | 280 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 17:32:49 |
| Calls: | 2,400 |
| Calls today: | 2 |
| Files: | 5,150 |
| D/L today: |
205 files (29,347K bytes) |
| Messages: | 437,079 |