先做一个释放的1.exe
再做一个管理用的2.exe 用把文件向1.exe 后面添加...
我马上要走了 25号回来,再给你代码

解决方案 »

  1.   

    要制作安装文件为什么不用installshield for delphi?即能做出exe,又能包含多个文件在里面,而却又不需要编程,根本不遥源码,不是很方便吗?
      

  2.   

    通过资源的方式把想安装的文件写到EXE文件中 —— 不用多说了吧
      

  3.   

    我有这方面的源程序,需要的话就个E_mail。
      

  4.   

    能不能发给小弟一个
    [email protected]
      

  5.   

    先做一个_X.exe,这个文件会释放文件
    然后做一个编译程序,这个程序可以将一些资源文件加到_X.exe后面,
    注意在增加资源后别忘了将文件的列表放进去哦,然后保存到X.exe文
    件中就行了。
    好了,这个时候可以设计_X.exe了,在程序启动的时候将自己读入到流
    中,从尾巴开始,读取文件列表,然后根据文件列表的纪录,分别读取
    文件生成文件。
    这就是单个安装程序的设计,当然可以加上角加密和压缩,可以扩充
    文件列表的结构哦。
      

  6.   

    SUNON,我也想要一份源程序!谢谢
    [email protected]
      

  7.   


       SUNON,我也想要一份源程序!最好给我点说明。谢谢
       [email protected]
      

  8.   

    一个流的例子!希望对你有用! 我们经常看到一些电子贺卡之类的制作软件,可以让你自己选择图片,然后
    它会生成一个EXE可执行文件给你。打开贺卡时就会一边放音乐一边显示出图片来。
    现在学了流操作之后,我们也可以做一个了。   
       添加图片过程我们可以直接用前面的Cjt_AddtoFile,而现在要做的是如何把
    图像读出并显示。我们用前面的Cjt_LoadFromFile先把图片读出来保存为文件再
    调入也是可以的,但是还有更简单的方法,就是直接把文件流读出来显示,有了
    流这个利器,一切都变的简单了。
        现在的图片比较流行的是BMP格式和JPG格式。我们现在就针对这两种图片写
    出读取并显示函数。Function Cjt_BmpLoad(ImgBmp:TImage;SourceFile:String):Boolean;
    var
     Source:TFileStream;
     MyFileSize:integer;
    begin
    Source:=TFileStream.Create(SourceFile,fmOpenRead or fmShareDenyNone);
    try
    try
    Source.Seek(-sizeof(MyFileSize),soFromEnd);
    Source.ReadBuffer(MyFileSize,sizeof(MyFileSize));//读出资源
    Source.Seek(-MyFileSize,soFromEnd);//定位到资源开始位置
    ImgBmp.Picture.Bitmap.LoadFromStream(Source);
    finally
    Source.Free;
    end;
    except
    Result:=False;
    Exit;
    end;
    Result:=True;
    end;
      上面是读出BMP图片的,下面的是读出JPG图片的函数,因为要用到JPG单元,所
    以要在程序中添加一句:uses jpeg。Function Cjt_JpgLoad(JpgImg:Timage;SourceFile:String):Boolean;
    var
     Source:TFileStream;
    MyFileSize:integer;
     Myjpg: TJpegImage;
    begin
    try
    Myjpg:= TJpegImage.Create;
    Source:=TFileStream.Create(SourceFile,fmOpenRead or fmShareDenyNone);
    try
    Source.Seek(-sizeof(MyFileSize),soFromEnd);
    Source.ReadBuffer(MyFileSize,sizeof(MyFileSize));
    Source.Seek(-MyFileSize,soFromEnd);
    Myjpg.LoadFromStream(Source);
    JpgImg.Picture.Bitmap.Assign(Myjpg);
    finally
    Source.Free;
    Myjpg.free;
    end;
    except
    Result:=false;
    Exit;
    end;
    Result:=true;
    end;
      有了这两个函数,我们就可以制作读出程序了。下面我们以BMP图片为例:
      运行Delphi,新建一个工程,放上一个显示图像控件Image1。在窗口的Create
    事件中写上一句就可以了:
       Cjt_BmpLoad(Image1,Application.ExeName);
      这个就是头文件了,然后我们用前面的方法生成一个head.res资源文件。
    下面就可以开始制作我们的添加程序了。全部代码如下:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ExtCtrls, StdCtrls, ExtDlgs;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
        Button2: TButton;
        OpenPictureDialog1: TOpenPictureDialog;
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
      Function ExtractRes(ResType, ResName, ResNewName : String):boolean;
      Function Cjt_AddtoFile(SourceFile,TargetFile:string):Boolean;
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}
    Function TForm1.ExtractRes(ResType, ResName, ResNewName : String):boolean;
    var
    Res : TResourceStream;
    begin
    try
    Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
    try
    Res.SavetoFile(ResNewName);
    Result:=true;
    finally
    Res.Free;
    end;
    except
    Result:=false;
    end;
    end;
    Function TForm1.Cjt_AddtoFile(SourceFile,TargetFile:string):Boolean;
    var
    Target,Source:TFileStream;
    MyFileSize:integer;
    begin
    try
    Source:=TFileStream.Create(SourceFile,fmOpenRead or fmShareExclusive);
    Target:=TFileStream.Create(TargetFile,fmOpenWrite or fmShareExclusive);
    try
    Target.Seek(0,soFromEnd);//往尾部添加资源
    Target.CopyFrom(Source,0);
    MyFileSize:=Source.Size+Sizeof(MyFileSize);//计算资源大小,并写入辅程尾部
    Target.WriteBuffer(MyFileSize,sizeof(MyFileSize));
    finally
    Target.Free;
    Source.Free;
    end;
    except
    Result:=False;
    Exit;
    end;
    Result:=True;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Caption:='Bmp2Exe演示程序.作者:陈经韬';
    Edit1.Text:='';
    OpenPictureDialog1.DefaultExt := GraphicExtension(TBitmap);
    OpenPictureDialog1.Filter := GraphicFilter(TBitmap);Button1.Caption:='选择BMP图片';
    Button2.Caption:='生成EXE';
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    if OpenPictureDialog1.Execute then
       Edit1.Text:=OpenPictureDialog1.FileName;
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
     HeadTemp:String;
    begin
    if FileExists(Edit1.Text) then
       begin
        Application.MessageBox('BMP图片文件不存在,请重新选择!','信息',MB_ICONINFORMATION+MB_OK)
        Exit;
       end;
     HeadTemp:=ChangeFileExt(Edit1.Text,'.exe');
     if ExtractRes('exefile','head',HeadTemp) then
         if Cjt_AddtoFile(Edit1.Text,HeadTemp) then
             Application.MessageBox('EXE文件生成成功!','信息',MB_ICONINFORMATION+MB_OK)
     else
         begin
          if FileExists(HeadTemp) then DeleteFile(HeadTemp);
          Application.MessageBox('EXE文件生成失败!','信息',MB_ICONINFORMATION+MB_OK)
         end;
    end;
    end.
       怎么样?很神奇吧:)把程序界面弄的漂亮点,再添加一些功能,你会发现比
    起那些要注册的软件来也不会逊多少吧。