⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jvquibobj.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  Result.ElementSize := ElementSize;
  Connection.ReadBuffer(Result.Bounds, 8 * DimCount);
  SafeArrayAllocData(Result);
  case DeCompress of
    False:
      begin
        SafeArrayAccessData(Result, DataPtr);
        try
          Connection.ReadBuffer(DataPtr^, SafeArrayElementTotal(Result) * ElementSize);
        finally
          SafeArrayUnaccessData(Result);
        end;
      end;
    True:
      begin
        Connection.ReadBuffer(InBytes, SizeOf(InBytes));
        if InBytes > 0 then
        begin
          SafeArrayAccessData(Result, DataPtr);
          GetMem(InBuf, InBytes);
          try
            Connection.ReadBuffer(InBuf^, InBytes);
            DecompressToUserBuf(InBuf, InBytes, DataPtr, SafeArrayElementTotal(Result) * ElementSize);
          finally
            FreeMem(InBuf, InBytes);
            SafeArrayUnaccessData(Result);
          end;
        end;
      end;
  end;
end;

function TJvUIBConnection.ReadPWideChar: PWideChar;
var
  StrCount: Integer;
begin
  Connection.ReadBuffer(StrCount, SizeOf(StrCount));
  if StrCount > 0 then
  begin
    GetMem(Result, StrCount);
    Connection.ReadBuffer(Result^, StrCount);
  end
  else
    Result := nil;
end;

function TJvUIBConnection.ReadReal48: Real48;
begin
  Connection.ReadBuffer(Result, SizeOf(Real48));
end;

function TJvUIBConnection.ReadShortint: Shortint;
begin
  Connection.ReadBuffer(Result, SizeOf(Shortint));
end;

function TJvUIBConnection.ReadSingle: Single;
begin
  Connection.ReadBuffer(Result, SizeOf(Single));
end;

function TJvUIBConnection.ReadSmallint: Smallint;
begin
  Connection.ReadBuffer(Result, SizeOf(Smallint));
end;

procedure TJvUIBConnection.ReadStream(Stream: TStream; DeCompress: Boolean = False);
var
  InPutBuffer, OutPutBuffer: Pointer;
  InPutSize, OutPutSize: Integer;
begin
  if DeCompress then
  begin
    InPutSize := ReadInteger;
    OutPutSize := ReadInteger;
    getmem(InPutBuffer, InPutSize);
    GetMem(OutPutBuffer, OutPutSize);
    Connection.ReadBuffer(InPutBuffer^, InPutSize);
    DecompressToUserBuf(InPutBuffer, InPutSize, OutPutBuffer, OutPutSize);
    FreeMem(InPutBuffer, InPutSize);
    Stream.Seek(0, soFromBeginning);
    Stream.Write(OutPutBuffer^, OutPutSize);
    FreeMem(OutPutBuffer, OutPutSize);
  end
  else
    Connection.ReadStream(Stream, ReadInteger);
end;

function TJvUIBConnection.ReadString: string;
var
  StrCount: Integer;
begin
  Connection.ReadBuffer(StrCount, SizeOf(StrCount));
  if StrCount > 0 then
  begin
    SetLength(Result, StrCount);
    Connection.ReadBuffer(Result[1], StrCount);
  end;
end;

function TJvUIBConnection.ReadVariant(DeCompress: Boolean): Variant;
begin
  VarClear(Result);
  Connection.ReadBuffer(TVarData(Result).VType, 2);
  // (rom) why not call the Read* methods?
  case TVarData(Result).VType of
    varEmpty:
      {Nothing to do};
    varNull:
     {Nothing to do};
    varSmallInt:
      Connection.ReadBuffer(TVarData(Result).VSmallInt, SizeOf(Smallint));
    varInteger:
      Connection.ReadBuffer(TVarData(Result).VInteger, SizeOf(Integer));
    varSingle:
      Connection.ReadBuffer(TVarData(Result).VSingle,  SizeOf(Single));
    varDouble:
      Connection.ReadBuffer(TVarData(Result).VDouble, SizeOf(Double));
    varCurrency:
      Connection.ReadBuffer(TVarData(Result).VCurrency, SizeOf(Currency));
    varDate:
      Connection.ReadBuffer(TVarData(Result).VDate, SizeOf(TDate));
    varOleStr:
      TVarData(Result).VOleStr := ReadPWideChar;
    varBoolean:
      // (rom) Beware! Size inconsistency!
      Connection.ReadBuffer(TVarData(Result).VBoolean, 2);
    {$IFDEF DELPHI6_UP}
    varShortInt:
      Connection.ReadBuffer(TVarData(Result).VShortInt, SizeOf(Shortint));
    varWord:
      Connection.ReadBuffer(TVarData(Result).VWord, SizeOf(Word));
    varLongWord:
      Connection.ReadBuffer(TVarData(Result).VLongWord, SizeOf(Longword));
    varInt64:
      Connection.ReadBuffer(TVarData(Result).VInt64, SizeOf(Int64));
    {$ENDIF DELPHI6_UP}
    varByte:
      Connection.ReadBuffer(TVarData(Result).VByte, SizeOf(Byte));
    varString:
      TVarData(Result).VString := ReadPChar;
  else
    if TVarData(Result).VType and varArray = varArray then
      TVarData(Result).VArray := ReadPVarArray(DeCompress)
    else
      raise EJvUIBException.Create(EJvUIB_DataType);
  end
end;

function TJvUIBConnection.ReadWideString: WideString;
var
  StrCount: Integer;
begin
  Connection.ReadBuffer(StrCount, SizeOf(StrCount));
  if StrCount > 0 then
  begin
    SetLength(Result, StrCount);
    Connection.ReadBuffer(Result[1], StrCount * SizeOf(WideChar));
  end;
end;

function TJvUIBConnection.ReadWord: Word;
begin
  Connection.ReadBuffer(Result, SizeOf(Word));
end;

function TJvUIBConnection.ReadWordBool: WordBool;
begin
  Connection.ReadBuffer(Result, SizeOf(WordBool));
end;

procedure TJvUIBConnection.WriteBoolean(Value: Boolean);
begin
  Connection.WriteBuffer(Value, SizeOf(Boolean));
end;

procedure TJvUIBConnection.WriteByte(Value: Byte);
begin
  Connection.WriteBuffer(Value, SizeOf(Byte));
end;

procedure TJvUIBConnection.WriteByteBool(Value: ByteBool);
begin
  Connection.WriteBuffer(Value, SizeOf(ByteBool));
end;

procedure TJvUIBConnection.WriteCardinal(Value: Cardinal);
begin
  Connection.WriteBuffer(Value, SizeOf(Cardinal));
end;

procedure TJvUIBConnection.WriteComp(Value: Comp);
begin
  Connection.WriteBuffer(Value, SizeOf(Comp));
end;

procedure TJvUIBConnection.WriteCurrency(Value: Currency);
begin
  Connection.WriteBuffer(Value, SizeOf(Currency));
end;

procedure TJvUIBConnection.WriteDouble(Value: Double);
begin
  Connection.WriteBuffer(Value, SizeOf(Double));
end;

procedure TJvUIBConnection.WriteExtended(Value: Extended);
begin
  Connection.WriteBuffer(Value, SizeOf(Extended));
end;

procedure TJvUIBConnection.WriteGUID(Value: TGUID);
begin
  Connection.WriteBuffer(Value, SizeOf(TGUID));
end;

procedure TJvUIBConnection.WriteInt64(Value: Int64);
begin
  Connection.WriteBuffer(Value, SizeOf(Int64));
end;

procedure TJvUIBConnection.WriteInteger(Value: Integer);
begin
  Connection.WriteBuffer(Value, SizeOf(Integer));
end;

procedure TJvUIBConnection.WriteLongBool(Value: LongBool);
begin
  Connection.WriteBuffer(Value, SizeOf(LongBool));
end;

procedure TJvUIBConnection.WriteLongint(Value: Longint);
begin
  Connection.WriteBuffer(Value, SizeOf(Longint));
end;

procedure TJvUIBConnection.WriteLongword(Value: Longword);
begin
  Connection.WriteBuffer(Value, SizeOf(Longword));
end;

procedure TJvUIBConnection.WriteOleVariant(var Value: OleVariant; Compress: Boolean);
begin
  WriteVariant(Variant(Value), Compress);
end;

procedure TJvUIBConnection.WritePChar(Value: PChar);
var
  StrCount: Integer;
begin
  StrCount := Length(Value);
  Connection.WriteBuffer(StrCount, SizeOf(StrCount));
  if StrCount > 0 then
    Connection.WriteBuffer(Value[1], StrCount);
end;

procedure TJvUIBConnection.WritePVarArray(Value: PVarArray; Compress: Boolean);
var
  DataPtr: Pointer;
  OutBuf: Pointer;
  OutBytes: Integer;
begin
  OutBytes := 0;
  OutBuf := nil;
  SafeArrayAccessData(Value, DataPtr);
  try
    Connection.WriteBuffer(Value^, 8); // DimCount + Flags + ElementSize
    Connection.WriteBuffer(Value^.Bounds, 8 * Value.DimCount); // Bounds
    case Compress of
      False:
        Connection.WriteBuffer(DataPtr^, SafeArrayElementTotal(Value) * Value.ElementSize);
      True:
        begin
          CompressBuf(DataPtr, SafeArrayElementTotal(Value) * Value.ElementSize, OutBuf, OutBytes);
          Connection.WriteBuffer(OutBytes, SizeOf(OutBytes));
          if OutBytes > 0 then
          begin
            Connection.WriteBuffer(OutBuf^, OutBytes);
            FreeMem(OutBuf, OutBytes);
          end;
        end;
    end;
  finally
    SafeArrayUnaccessData(Value);
  end;
end;

procedure TJvUIBConnection.WritePWideChar(Value: PWideChar);
var
  StrCount: Integer;
begin
  StrCount := Length(Value) * 2 + 2;
  Connection.WriteBuffer(StrCount, SizeOf(StrCount));
  if StrCount > 0 then
    Connection.WriteBuffer(Value[1], StrCount);
end;

procedure TJvUIBConnection.WriteReal48(Value: Real48);
begin
  Connection.WriteBuffer(Value, SizeOf(Real48));
end;

procedure TJvUIBConnection.WriteShortint(Value: Shortint);
begin
  Connection.WriteBuffer(Value, SizeOf(Shortint));
end;

procedure TJvUIBConnection.WriteSingle(Value: Single);
begin
  Connection.WriteBuffer(Value, SizeOf(Single));
end;

procedure TJvUIBConnection.WriteSmallint(Value: Smallint);
begin
  Connection.WriteBuffer(Value, SizeOf(Smallint));
end;

procedure TJvUIBConnection.WriteStream(Stream: TStream; Compress: Boolean = False);
var
  InPutBuffer, OutPutBuffer: Pointer;
  InPutSize, OutPutSize: Integer;
begin
  if Compress then
  begin
    InPutSize := Stream.Size;
    GetMem(InPutBuffer, InPutSize);
    Stream.Seek(0, soFromBeginning);
    Stream.Read(InPutBuffer^, InPutSize);
    CompressBuf(InPutBuffer, InPutSize, OutPutBuffer, OutPutSize);
    FreeMem(InPutBuffer, InPutSize);
    WriteInteger(OutPutSize);
    WriteInteger(InPutSize);
    Connection.WriteBuffer(OutPutBuffer^, OutPutSize);
    freemem(OutPutBuffer, OutPutSize);
  end
  else
  begin
    WriteInteger(Stream.Size);
    Connection.WriteStream(Stream);
  end;
end;

procedure TJvUIBConnection.WriteString(Value: string);
var
  StrCount: Integer;
begin
  StrCount := Length(Value);
  Connection.WriteBuffer(StrCount, SizeOf(StrCount));
  if StrCount > 0 then
    Connection.WriteBuffer(Value[1], StrCount);
end;

procedure TJvUIBConnection.WriteVariant(var Value: Variant;
  Compress: Boolean);
begin
  Connection.WriteBuffer(TVarData(Value).VType, 2);
  // (rom) why not call the Write* methods here?
  case TVarData(Value).VType of
    varEmpty:
      {Nothing to do};
    varNull:
      {Nothing to do};
    varSmallInt:
      Connection.WriteBuffer(TVarData(Value).VSmallInt, SizeOf(Smallint));
    varInteger:
      Connection.WriteBuffer(TVarData(Value).VInteger, SizeOf(Integer));
    varSingle:
      Connection.WriteBuffer(TVarData(Value).VSingle, SizeOf(Single));
    varDouble:
      Connection.WriteBuffer(TVarData(Value).VDouble, SizeOf(Double));
    varCurrency:
      Connection.WriteBuffer(TVarData(Value).VCurrency,  SizeOf(Currency));
    varDate:
      Connection.WriteBuffer(TVarData(Value).VDate,  SizeOf(TDate));
    varOleStr:
      WritePWideChar(TVarData(Value).VOleStr);
    varBoolean:
      // (rom) Beware! Size inconsistency!
      Connection.WriteBuffer(TVarData(Value).VBoolean, 2);
    {$IFDEF DELPHI6_UP}
    varShortInt:
      Connection.WriteBuffer(TVarData(Value).VShortInt,  SizeOf(Shortint));
    varWord:
      Connection.WriteBuffer(TVarData(Value).VWord,  SizeOf(Word));
    varLongWord:
      Connection.WriteBuffer(TVarData(Value).VLongWord,  SizeOf(Longword));
    varInt64:
      Connection.WriteBuffer(TVarData(Value).VInt64,  SizeOf(Int64));
    {$ENDIF DELPHI6_UP}
    varByte:
      Connection.WriteBuffer(TVarData(Value).VByte,  SizeOf(Byte));
    varString:
      WritePChar(TVarData(Value).VString);
  else
    if TVarData(Value).VType and varArray = varArray then
      WritePVarArray(TVarData(Value).VArray, Compress)
    else
      raise EJvUIBException.Create(EJvUIB_DataType);
  end;
end;

procedure TJvUIBConnection.WriteWideString(Value: WideString);
var
  StrCount: Integer;
begin
  StrCount := Length(Value);
  Connection.WriteBuffer(StrCount,  SizeOf(StrCount));
  if StrCount > 0 then
    Connection.WriteBuffer(Value[1], StrCount *  SizeOf(WideChar));
end;

procedure TJvUIBConnection.WriteWord(Value: Word);
begin
  Connection.WriteBuffer(Value, SizeOf(Word));
end;

procedure TJvUIBConnection.WriteWordBool(Value: WordBool);
begin
  Connection.WriteBuffer(Value, SizeOf(WordBool));
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -