MapTextFileFrm.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:1k
源码类别:
Delphi/CppBuilder
开发平台:
Delphi
- unit MapTextFileFrm;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, UMapTextFile, StdCtrls;
- type
- Tfrm_MapTextFile = class(TForm)
- Button4: TButton;
- procedure Button4Click(Sender: TObject);
- private
- MapTextFile: TMapTextFile;
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frm_MapTextFile: Tfrm_MapTextFile;
- implementation
- {$R *.dfm}
- procedure Tfrm_MapTextFile.Button4Click(Sender: TObject);
- var
- aWriteString: PByte; //写入的数据
- aPos: Longint; //写入位置
- aSize: Longint; // 写入数据大小
- aReadString: string; //读出的字符串
- aTextChar: char; //读出的字符
- begin
- //创建MapTextFile对象,并进行相关设置
- MapTextFile := TMapTextFile.Create;
- MapTextFile.FileName := 'E:wb2.txt';
- MapTextFile.FileCreateSize := 200;
- MapTextFile.FileMode := fmCreate;
- MapTextFile.open;
- //向文件里写入数据
- move('abcefg', aWriteString, 6);
- aPos := MapTextFile.GetPos;
- MapTextFile.WriteBytes(aWriteString, aPos, 6);
- //从文件里读数据,并显示
- MapTextFile.SetPos(0);
- aReadString := MapTextFile.ReadString;
- MapTextFile.SetPos(2);
- aTextChar := MapTextFile.ReadChar;
- ShowMessage(aReadString);
- ShowMessage(aTextChar);
- //从文件里查找字符串'c'
- ShowMessage(IntTostr(MapTextFile.FindString('c', 0, 4)));
- //MapTextFile释放
- MapTextFile.Close;
- end;
- end.