我的学习生涯(Delphi篇) - 00

来源:互联网 发布:淘宝里怎么看闲鱼卖的 编辑:程序博客网 时间:2024/04/30 02:41

    写在开篇!

    很高兴在CSDN这个平台与广大的开发者交流心得。

    毕业后,一直在学习Delphi。说来也许可笑:上学时,Pascal考试不及格!所以,天天看看Pascal的书。

    04进了一家私企使用就是Delphi。使自己对在Windows平台使用Delphi进行C/S有了坚定的信心!

    直到现在,我还是认为在Windows平台最好的C/S开发工具非Delphi莫属!


------------------------------------以下版本仅供学习使用,请不要用于商业用途---------------------------------------------

Delphi 6: http://pan.baidu.com/s/1nurDnzr

Delphi 7: http://pan.baidu.com/s/1kTSEP8r

Delphi 7 update (for vista) 


    -------------------------------------------------------------------------------------------------美丽分割线---------------------------

    年代:2005

    文件:my0501.7z


    效果如下图:

    

    Unit1.pas

    

unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls, ExtCtrls;type  TForm1 = class(TForm)    Memo1: TMemo;    OpenDialog1: TOpenDialog;    Panel1: TPanel;    Panel2: TPanel;    Button1: TButton;    Button2: TButton;    Button3: TButton;    Button4: TButton;    Button5: TButton;    procedure Button1Click(Sender: TObject);    procedure Button2Click(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure Button3Click(Sender: TObject);    procedure Button4Click(Sender: TObject);    procedure Button5Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;  filenames:string;  function GetTextFromFile(AFile : String; var ReturnString : string) : boolean;implementation{$R *.dfm}function GetTextFromFile(AFile : String; var ReturnString : string) : boolean;varFileStream : TFileStream;begin  result := false;  if not fileexists(AFile) then exit;  FileStream := TFileStream.Create(AFile,fmopenreadwrite);  try    if FileStream.Size > 0 then    begin      SetLength(ReturnString,FileStream.size);      FileStream.Read(ReturnString[1],FileStream.Size);      result := true;    end  finally    FileStream.Free;  end;end;procedure TForm1.Button1Click(Sender: TObject);var  s : string;  buffer1:PChar;begin  try    OpenDialog1.InitialDir:='d:\';    OpenDialog1.Filter:='数据文件(*.xbf)| *.xbf';    if OpenDialog1.Execute then    begin      filenames:=OpenDialog1.FileName;    end;  except  end;  if GetTextFromFile(filenames,s)  then  begin    // Label1.caption := s; or assign the text to a Label     Memo1.text := s;  end;  end;procedure TForm1.Button2Click(Sender: TObject);begin  Application.Terminate;end;procedure TForm1.FormCreate(Sender: TObject);begin  Form1.Caption:='打开数据文件';  form1.BorderStyle:=bsSingle;end;procedure TForm1.Button3Click(Sender: TObject);begin   Memo1.Lines.SaveToFile(filenames);end;procedure TForm1.Button4Click(Sender: TObject);var  sfi,si:integer;  buff:array [0..4096] of byte;  s:string;begin   try    OpenDialog1.InitialDir:='d:\';    OpenDialog1.Filter:='报文文件(*.rep)| *.rep';    if OpenDialog1.Execute then    begin      filenames:=OpenDialog1.FileName;    end;  except  end;   //sfi:=FileOpen(filenames,fmOpenReadWrite);   //if sfi=-1 then exit; //文件不存在// FileSeek(sfi,where,0); // 指定要读位置,0:从文件头计起   //si:=FileRead(sfi,buff,4096); //读入多少字节的数据   //FileSeek(sfi,where,0); // 指定要写位置,0:从文件头计起,2:从文件尾倒数   //filewrite(sfi,buff,4096);   //FileClose(sfi);   if GetTextFromFile(filenames,s)  then  begin    // Label1.caption := s; or assign the text to a Label     Memo1.text := s;  end;end;procedure TForm1.Button5Click(Sender: TObject);var  Buffer: PChar;begin  GetMem(Buffer,Length(Memo1.Text) + Length(Memo1.Text) + 1);  StrCopy(Buffer, PChar(Memo1.Text));  StrCat(Buffer, PChar(Memo1.Text));  Memo1.Text := Buffer;  FreeMem(Buffer);end;end.



原创粉丝点击