CopyMemory无法复制常量指针?解决方案

CopyMemory无法复制常量指针?

const
  CONST_NAME = 'TEST';

CopyMemory(@SendBuf, @CONST_NAME, strLen(CONST_NAME));

//出错求解释

------解决方案--------------------
CONST_NAME应该是一个字符串
应该这样
@CONST_NAME[1]
------解决方案--------------------
可以复制的,请看下面的示例,@CONST_NAME[1]下标从1开始
Delphi(Pascal) code

const
  CONST_NAME = 'TEST';
var
  SendBuf: array of Byte;
  i: Integer;
begin
  SetLength(SendBuf,4);
  CopyMemory(@SendBuf[0], @CONST_NAME[1], strLen(CONST_NAME));
  for i := Low(SendBuf) to High(SendBuf) do
    ShowMessage(Char(SendBuf[i]));
end;

------解决方案--------------------
const
CONST_NAME = 'TEST';

CopyMemory(@SendBuf, PChar(CONST_NAME), SizeOf(char)*strLen(CONST_NAME));