怎样做一个可以去编译.exe文件的程序?

Benjamin 2000-02-29 07:10:00
见标题,谢谢.
...全文
387 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
kevinluo 2000-03-15
  • 打赏
  • 举报
回复
看看《 编译原理 》 ,然后拿段源代码看看,比如说Gcc的代码。
Benjamin 2000-03-15
  • 打赏
  • 举报
回复
那么怎么实现呢?很抱歉我知识量太小了,你能举个简单的例子吗?我想不少人都对此感兴趣。
多谢。
Leex2000 2000-03-13
  • 打赏
  • 举报
回复
几乎可以肯定不是!你知道 WinZip 把 .ZIP 转换为 .EXE 文件的原理,那就是
解压缩程序 + Zip包. 所有的解压缩程序都是同一个,不同的只是 Zip 部分。
解压缩程序先打开自己,然后确定数据部分,然后怎么做就看你自己的了。
Benjamin 2000-03-12
  • 打赏
  • 举报
回复
那么,那个中国程序员做的“音乐贺卡厂2000”用的不是编译器吗?如果不是,那是怎样实现生成exe文件的?
csdn2000 2000-03-11
  • 打赏
  • 举报
回复
我觉得自己做编译器没有必要,除非你想出个ZC++/XB/Eelphi之类的编译器给人用。我倒认为Lin的方案更加切中你的问题。
Leex2000 2000-03-09
  • 打赏
  • 举报
回复
从头说有点长,可要有耐心呀。
1、编译原理一定要看的
2、找一个 Yacc 的程序帮你订做语法分析器
3、把语法分析器生成的逻辑代码转换为本地的机器码(我知道的也不多)
建议:
GNU 的 GCC 是有源程序的,Download 一份看看。
LCC 是一份 Win32 下的 C 编译器,但源程序光盘要 $
Bloodshed Dev-C++ 3.8 也是一个免费的 C++ 编译器, 有源程序,不要 $
Turbo Pascal 6.0 的源程序在网上能找到.
如果不是真的有必要,别自己做编译器,解释执行也不错,VB、PowerBuilder 都是解释执行的,但也是个 exe 文件。

Benjamin 2000-03-07
  • 打赏
  • 举报
回复
天! dnchen大虾,i'm 17,could u give me a exactly explanation?
bruce_zhao,你的回答好像...我要是用资源文件读取,这么简单,何必在csdn上提问. :)
Un1 2000-03-05
  • 打赏
  • 举报
回复
原来是这样,这让我想起了 ReadMe.EXE。
huiwsey 2000-03-04
  • 打赏
  • 举报
回复
是Delphi 6的意思吗?
dnchen 2000-03-04
  • 打赏
  • 举报
回复
懒的写文章,刚好有外国人的文档,拿去看吧,程序很容易实现,

> Does anyone know how you can calcualate the real size of an EXE file so you
> know where the position in the EXE file is where there's an external data
> file attatched.
>
> e.g. a file create by
> COPY /B TEST.EXE + TEST.DTA PROG.EXE
>
> I can do it in plain old Dos but i cant get i to work in Delphi.

You can't. Windows binaries have all sorts of things in them
that it is difficult to pinpoint exactly where the binary ends from
the information in the header. PE (Win32) binaries are even worse
than NE (Win16) binaries in this respect.

My advice is join the data to the EXE via source code, and
then to write a little header to the end of the joined file which
contains offsets to the beginning and end of the data.

e.g.,
1. create a record;
Var MyRec = Record
Signature : String[4];
ExeSize,
DataSize: Longint;
end;

2. open your EXE file and your data file

3. fill the record;
With MyRec do begin
Signature := #4#3#3#5; {a unique signature}
ExeSize := FileSize(MyExeFile);
DataSize := FileSize(MyDataFile);
end;

4. create destination file
5. copy EXE file into it (using BlockRead/BlockWrite)
6. then copy data file into it (--ditto--)
7. then write the record to it (using BlockWrite)
8. close all files

When you want to read the data, all you need to do is
to;
1. open the file
2. Seek(MyFile, FileSize(MyFile)-Sizeof(MyRec))
3. BlockRead(MyFile, MyRec, Sizeof(MyRec))
4. do checks -
- If Ioresult = 0
- and MyRec.Signature = #4#3#3#5
- and MyRec.ExeSize > 0
- and MyRec.DataSize > 0
then - everything is okay
- so
- Seek(MyFile, MyRec.ExeSize)
- read your data, until MyRec.DataSize,
etc, etc.

All this may look tedious and involved - but believe me,
it is *far* less tedious than trying to walk through the
PE header.

yxf 2000-03-04
  • 打赏
  • 举报
回复
想要编译Delphi的程序,可以调用dcc32.exe(Delphi4),或者调用Delphi的编译菜单项。
bruce_zhao 2000-03-03
  • 打赏
  • 举报
回复
要做个可执行的贺卡,其实只需将贺卡内容放到资源文件中,然后在程序中读出来,进行显示不就行了.
Lin 2000-03-03
  • 打赏
  • 举报
回复
Benjamin:
我认为制作这样的程序并不需要作一个编译器,只需作好一个Exe文件,然后将数据文件附在后面,执行时Exe文件读取数据处理就行了.
sundaynews 2000-03-03
  • 打赏
  • 举报
回复
你应该知道ZIP文件自解压的执行文件吧,贺卡程序也不过如此。如果需要自解压程序的例子,M我,我给你。自作一个编译器的工程量太大,尽管原理挺简单的。
Un1 2000-03-03
  • 打赏
  • 举报
回复
啃透《编译原理》再说!
Benjamin 2000-03-01
  • 打赏
  • 举报
回复
比如说,一些可生成.exe文件的贺卡制作软件,它们是怎么做的?
这是除了分布式编程以外,我最想知道的问题。
jll 2000-03-01
  • 打赏
  • 举报
回复
老天,我的计算机专业课中学得最差的之一就是《编译原理》了。我苦……
课本上好象有一个例子,但不是编译成EXE,而是在C或Pascal环境中实现编译。
如果做好的话,也给我M一份,要是你用Pascal编写的话,说不定我还能帮忙!
Benjamin 2000-03-01
  • 打赏
  • 举报
回复
我是想问怎样做一个编译器。
caili 2000-03-01
  • 打赏
  • 举报
回复
去找一找FreePascal
Lin 2000-02-29
  • 打赏
  • 举报
回复
是不是想修改Exe文件的资源呀?这样的工具我倒有一个。
如果想做编译器,我.....第一个用,做好的话。
加载更多回复(2)

5,385

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧