When i try to compile my code I get the below error. Could anyone suggest what am I doing wrong here?
W1000 Symbol 'StrPas' is deprecated: 'Moved to the AnsiStrings unit'
The code fragment that i'm trying to compile is:
{$IFDEF NEWVER} // Codegear delphi 2009 d12.0
StrCopy(pSerialNumber, @Buf[pDevDesc.SerialNumberOffset + 1]);
{$ELSE}
StrPCopy(pSerialNumber,
FlipAndCodeBytes(StrPas(@Buf[pDevDesc.SerialNumberOffset + 1])));
{$ENDIF}
The documentation has the answer. It says:
This function is provided for backwards compatibility only. To convert a null-terminated string to an AnsiString or native Delphi language string, use a typecast or an assignment.
So instead of StrPas(...)
you should cast to either AnsiString
or UnicodeString
depending on whether or not the buffer is 8 bit or 16 bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With