var mStream: TMemoryStream; vcode: array[0..49] of AnsiChar; buffer: array of AnsiChar; begin mStream := TMemoryStream.Create; mStream.LoadFromFile('1.png'); //GetMem(vcode, 50); ShowMessage('1'); SetLength(buffer, mStream.Size); mStream.Position := 0; ShowMessage('2'); mStream.ReadBuffer(buffer[0], mStream.Size); ShowMessage('3'); //if GetCodeText(buffer, mStream.Size, '输入前4位图像校验码', vcode) then //第一种 if GetCodeText(Integer(@buffer[0]), mStream.Size, '输入前4位图像校验码', vcode) then //第二种 Edit1.Text := Format('识别成功:%s', [string(vcode)]) else Edit1.Text := '识别失败'; ShowMessage('4'); mStream.Free; end;