小编Vla*_*tin的帖子

如何使用HTTP post方法发送位图

我想用HTTP POST方法发送位图图像.如何将其发送到URL?

我使用的是Indy 10和Delphi 10.1.在一个过程中,我创建了一个TStringList包含所有参数值,但我不知道如何传递位图数据.

这是我的代码:

procedure TuDm_Athlos.AddComandaInsertLogo(workList: TStringList;
  imageStream: TStream);
var
  image : TBitmap;
begin
  try
    image := TBitmap.Create;
    imageStream := TStream.Create;
    image.LoadFromFile('D:\\COFEE.BMP');
    image.SaveToStream(imageStream);
    workList.Add('db=titles');
    workList.Add('line_1=');
    worklist.Add('line_2=');
    workList.Add('line_3=');
    workList.Add('line_4=');
    workList.Add('line_5=');
    workList.Add('line_6=');
    workList.Add('store=&DB=PRN_UDG');
    workList.Add('code=1');
    workList.Add('width=' + IntToStr(image.Width));
    workList.Add('height=' + IntToStr(image.Height));
    workList.Add('length=576');
    workList.Add('store=');
  finally
    FreeAndNil(imageStream);
  end;
end;

function TuDm_Athlos.InsertLogo(imageStream: TStream;
  isFullResponse: Boolean): Boolean;
var
  StrResult     : UTF8String;
  workList      : TStringList;
  ContentStream : TStream;
  image         : TBitmap;
begin
  //Setup;
  Result := False;
  try
    try
      workList          := TStringList.Create;
      ContentStream     := …
Run Code Online (Sandbox Code Playgroud)

delphi indy http-post indy10 delphi-10.1-berlin

1
推荐指数
1
解决办法
599
查看次数

为什么从dll调用函数并使用record时会出现访问冲突?

我尝试调用一个函数以从c ++ dll中读取一些字节。我声明了函数的头,但是当我调用并尝试将数组值分配给记录值时,函数在MSVCR80.dll中返回访问冲突。这是我的代码,如果我使用valueBits记录,则返回AV,如果我使用一个简单的布尔变量,它将起作用。我需要一个建议。

    function TdmCustom.CheckBon(var valueBits: TStatusPrintingRecord): Boolean;
    var cmd          : String;
    //valueBit     : array[0..10] of AnsiChar;
    MemArea      : PAnsiChar;
    pdwByteRead  : LPDWORD;
    lpdwSysError : LPDWORD;
    aNrComanda   : String;
    Arr          : array of AnsiChar;
begin
  pdwByteRead  := 0;
  lpdwSysError := 0;
  aNrComanda   := '1011';
  cmd        := Format('%S',[aNrComanda]);
  SendCommandToPrinter(cmd,True);
  lastError := CEFReadB(MemArea, &pdwByteRead, &lpdwSysError)//acess violation if i use valueBits record
  SetLength(Arr, Integer(pdwByteRead));
  Move(MemArea^, Arr[0], Integer(pdwByteRead));
  if lastError = 0 then begin
    valueBits.S8_isBonFiscalDeschis   := Arr[8] = '1';
    //valueBits.S9_isBonNefiscalDeschis := Arr[9] = '1'; …
Run Code Online (Sandbox Code Playgroud)

delphi dll

1
推荐指数
1
解决办法
87
查看次数

标签 统计

delphi ×2

delphi-10.1-berlin ×1

dll ×1

http-post ×1

indy ×1

indy10 ×1