急:关于读文件的问题,希望各位多帮忙!!!
chm的文件格式不知大家是否知道?
http://www.speakeasy.org/~russotto/chm/chmformat.html
我想读出chm文件的内容,请问如何操作呢?
问题点数:20、回复次数:7Top
1 楼lonoaer()回复于 2006-07-03 16:24:01 得分 0
既然已经知道文件的结构,那就好办了,用TFILESTREAM或者内存映射文件的方式都可以
我一般都用后者:fileopen,fileseek, fileread,filecloseTop
2 楼btlxy(平凡)回复于 2006-07-03 16:29:07 得分 0
关键遇到了问题:
0000: char[4] 'PMGL'
0004: DWORD Length of free space and/or quickref area at end of
directory chunk
0008: DWORD Always 0.
000C: DWORD Chunk number of previous listing chunk when reading
directory in sequence (-1 if this is the first listing chunk)
0010: DWORD Chunk number of next listing chunk when reading
directory in sequence (-1 if this is the last listing chunk)
0014: Directory listing entries (to quickref area) Sorted by
filename; the sort is case-insensitive.
The quickref area is written backwards from the end of the chunk. One quickref entry exists for every n entries in the file, where n is calculated as 1 + (1 << quickref density). So for density = 2, n = 5.
Chunklen-0002: WORD Number of entries in the chunk
Chunklen-0004: WORD Offset of entry n from entry 0
Chunklen-0008: WORD Offset of entry 2n from entry 0
Chunklen-000C: WORD Offset of entry 3n from entry 0
...
The format of a directory listing entry is as follows
ENCINT: length of name
BYTEs: name (UTF-8 encoded)
ENCINT: content section
ENCINT: offset
ENCINT: length
不知道这时如何解决?Top
3 楼btlxy(平凡)回复于 2006-07-03 16:31:35 得分 0
我读到以上的地方,不知道如何办了?Top
4 楼lonoaer()回复于 2006-07-03 16:50:39 得分 0
0000: char[4] 'PMGL'
fileseek(aHnd, 0, 0);
fileread(aHnd, Buf, 4);
buf -> 'PMGL'Top
5 楼btlxy(平凡)回复于 2006-07-03 17:02:56 得分 0
主要到了这里:
0014: Directory listing entries (to quickref area) Sorted by
filename; the sort is case-insensitive.
如何解决????Top
6 楼btlxy(平凡)回复于 2006-07-03 17:03:27 得分 0
如何读取?Top
7 楼btlxy(平凡)回复于 2006-07-04 08:25:13 得分 0
早上好!
希望大家多多帮忙!Top




