Hi
I think this is a simple one for people who get widestrings and pointers better than me. I am using a Delphi API with Lazarus (using {mode DELPHI}) and one of the functions outputs text to an output message using LPWSTR (long pointer to wide string).
What I have below does compile but I am struggling getting it to output anything (it outputs empty lines currently).
function X_ProcessItem(nItemID : LongWord; lpReserved : Pointer) : integer; stdcall; export;
var
ItemSize : Int64;
ItemSizeWStr : WideChar;
Buf : array[0..1000000] of WideChar; // because I can't do array[0..Buflen-1] of WideChar for some reason)
begin
ItemSize := XAPI_GetItemSize(nItemID); // One API call. Gets the size and returns an Int64
StringToWideChar(IntToStr(ItemSize), @ItemSizeWStr, Length(ItemSizeWStr)); // IntToStr won't give me a widechar as needed for the output API function so doing this to convert.
lstrcpyw(Buf, @ItemSizeWStr); // this is from the Windows API, and it should copy the widestring to the Buffer
XAPI_OutputMessage(@Buf[0], 0); // The last API call that should output the content of the Buffer, ideally "12345" (or whatever the value of ItemSize is
end;
Where am I going wrong please?