Cyborg
Гость
|
|
« Ответ #4 : 01-04-2005 11:44 » |
|
Простенький пример (из Help'a). Кодируем картинку в текст. Текст в картинку. Работа с файлами. Как переделать для работы с Memo думаю понятно.
unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, NMUUE, ExtCtrls;
type TForm1 = class(TForm) NMUUProcessor1: TNMUUProcessor; BOpen: TButton; EIn: TEdit; EOut: TEdit; BCode: TButton; BDecode: TButton; OpenDialog1: TOpenDialog; RBMime: TRadioButton; RBCode: TRadioButton; procedure BOpenClick(Sender: TObject); procedure BCodeClick(Sender: TObject); procedure BDecodeClick(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.BOpenClick(Sender: TObject); begin if OpenDialog1.Execute then EIn.Text := OpenDialog1.FileName; end;
procedure TForm1.BCodeClick(Sender: TObject); var FS1, FS2: TFileStream; begin // Encode FS1 := TFileStream.Create(EIn.Text, fmOpenRead); FS2 := TFileStream.Create(EOut.Text, fmCreate); try if RBCode.Checked then NMUUProcessor1.Method := uuCode else NMUUProcessor1.Method := uuMime; NMUUProcessor1.InputStream := FS1; NMUUProcessor1.OutputStream := FS2; NMUUProcessor1.Encode; finally FS1.Free; FS2.Free; end; end;
procedure TForm1.BDecodeClick(Sender: TObject); var FS1, FS2: TFileStream; begin // Decode FS1 := TFileStream.Create(EOut.Text, fmOpenRead); FS2 := TFileStream.Create(EIn.Text, fmCreate); try if RBMime.Checked then NMUUProcessor1.Method := uuMime else NMUUProcessor1.Method := uuCode; NMUUProcessor1.InputStream := FS1; NMUUProcessor1.OutputStream := FS2; NMUUProcessor1.Decode; finally FS1.Free; FS2.Free; end;
end;
end.
|