SaveComponentByFile

绿草416

绿草416

2016-02-19 13:22

图老师小编精心整理的SaveComponentByFile希望大家喜欢,觉得好的亲们记得收藏起来哦!您的支持就是小编更新的动力~
unit savecomponent1;

  interface

  uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, Db, DBTables;

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

  type
    TForm1 = class(TForm)
      Button1: TButton;
      Query1: TQuery;
      ListBox1: TListBox;
      Button2: TButton;
      Button3: TButton;
      Button4: TButton;
      Label1: TLabel;
      Query2: TQuery;
      Button5: TButton;
      Edit1: TEdit;
      procedure Button1Click(Sender: TObject);
      procedure Button2Click(Sender: TObject);
      procedure Button3Click(Sender: TObject);
      procedure Button4Click(Sender: TObject);
      procedure Button5Click(Sender: TObject);
      procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    private
      { Private declarations }
    public
      { Public declarations }
    end;

  var
    Form1: TForm1;

  implementation

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

  {$R *.DFM}

  procedure TForm1.Button1Click(Sender: TObject);
  var
    F:TMemoryStream;
    Path:string;
    Filename:string;
  begin
    Path:=ExtractFilePath(application.ExeName);
    FileName:=Path+'ListBox.ini';
    F:=TMemorystream.Create ;
    F.WriteComponent(Listbox1);
    F.SaveToFile(Filename);
    F.Free;
    listbox1.Free;
  end;

  procedure TForm1.Button2Click(Sender: TObject);
  var
    F:TMemoryStream;
    Path:string;
    Filename:string;
    xx:Tlistbox;
  begin
    xx:=Tlistbox.create(self);
    xx.parent:=self;
    Path:=ExtractFilePath(application.ExeName);
    FileName:=Path+'ListBox.ini';
    F:=TMemorystream.Create ;
    F.LoadFromFile(Filename);
    xx:=TListBox(F.ReadComponent(xx));
    F.Free;
  end;

  procedure TForm1.Button3Click(Sender: TObject);
  var
    Path:string;
    Filename:string;
  begin
    Path:=ExtractFilePath(application.ExeName);
    FileName:=Path+'ListBox.ini';
    with query1 do
      begin
        close;requestlive:=true;sql.clear;databasename:='OILREP44444';
        SQL.Add('select * from zy_query');
        open;insert;
        fieldbyname('qry_id').asinteger:=strtoint(edit1.text);
        TBlobfield(Fieldbyname('sql_blob')).loadfromfile(Filename);
        try
          post;
        except
          close;
        end;
      end;
  end;

  procedure TForm1.Button4Click(Sender: TObject);
  var
    Path:string;
    Filename:string;
  begin
    Path:=ExtractFilePath(application.ExeName);
    FileName:=Path+'ListBox.ini';
    with query1 do
      begin
        close;sql.clear;databasename:='OILREP44444';
        SQL.Add('select * from zy_query where qry_id=:qq');
        params[0].AsInteger:=strtoint(edit1.text);
        try
          open;
          TBlobfield(Fieldbyname('sql_blob')).savetofile(Filename);
        except
          close;
        end;
      end;
  end;

  procedure TForm1.Button5Click(Sender: TObject);
  begin
  listbox1.Free;
  end;

展开更多 50%)
分享

猜你喜欢

SaveComponentByFile

编程语言 网络编程
SaveComponentByFile

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

excel2010怎么给文档加密

excel2010怎么给文档加密

文件与目录

文件与目录
下拉加载更多内容 ↓