Question

In a dll build with Delphi 2006

Foo(aPath: widestring);
begin
  _rootPath := aPath;
end;

In an executable built with Delphi 2010

_Foo := GetProcAddress(FooModule,’Foo’);
_Foo(‘123456’);

Stepping into the dll, aPath = '123'. In fact any string I pass gets cut exactly in half.

1.) Why is my literal being halved? 2.) How do I fix it?

Was it helpful?

Solution

Make sure the _Foo parameter is a widestring in 2010

OTHER TIPS

WideStrings reside in Windows heap and are not managed by Delphi memory manager. So WideStrings (unlike other long string types) can be shared between exe and dll without problems.

I suppose you get wrong data because WideString is a managed type and the memory manager for the dll and the executable are different. If you can recompile the dll make aPath type to be PWideChar

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top