请输入您要查询的百科知识:

 

词条 LZOpenFile
释义

LZOpenFile

VB声明

Declare Function LZOpenFile Lib "lz32.dll" Alias "LZOpenFileA" (ByVal lpszFile As String, lpOf As OFSTRUCT, ByVal style As Long) As Long

说明

该函数能执行大量不同的文件处理,而且兼容于压缩文件

返回值

Long,如函数执行成功,且样式(style)参数不为OF_READ,就返回常规的文件句柄,具体请参考OpenFile函数的说明。如样式参数为OF_READ,而且文件是压缩的,就会返回一个特殊的文件句柄,以便由LZCopy, LZRead 和 LZSeek函数使用。如出错,返回如下表所示的一个常数:

LZERROR_BADINHANDLE 源文件无效

LZERROR_BADOUTHANDLE 目标文件无效

LZERROR_GLOBALLOC 内部解压缓冲区的内存容量不足

LZERROR_GLOBLOCK 内部解压缓冲区的句柄无效

LZERROR_READ 无效的源文件格式

LZERROR_UNKNOWNALG 解压DLL不能识别源文件采用的压缩算法

LZERROR_WRITE 在磁盘上写入输出文件时出错,通常是由于磁盘空间不足造成的

实例:Private Type OFSTRUCT

cBytes As Byte

fFixedDisk As Byte

nErrCode As Integer

Reserved1 As Integer

Reserved2 As Integer

szPathName As String * 128

End Type

Private Declare Function LZOpenFile Lib "lz32.dll" Alias "LZOpenFileA" (ByVal lpszFile As String, lpOf As OFSTRUCT, ByVal style As Long) As Long

Private Declare Function LZCopy Lib "lz32.dll" (ByVal hfSource As Long, ByVal hfDest As Long) As Long

Private Declare Sub LZClose Lib "lz32.dll" (ByVal hfFile As Long)

Const OF_READ = &H0

Const OF_CREATE = &H1000

Const LZERROR_BADINHANDLE = (-1)

Const LZERROR_BADOUTHANDLE = (-2)

Const LZERROR_BADVALUE = (-7)

Const LZERROR_GLOBLOCK = (-6)

Const LZERROR_PUBLICLOC = (-5)

Const LZERROR_READ = (-3)

Const LZERROR_UNKNOWNALG = (-8)

Const LZERROR_WRITE = (-4)

Private Sub Form_Load()

'KPD-Team 1999

Dim SourceStruct As OFSTRUCT, DestStruct As OFSTRUCT

Dim hSource As Long, hDest As Long, lResults As Long

'Open the source- and the destination-files

hSource = LZOpenFile("c:\\myfile.tx_", SourceStruct, OF_READ)

hDest = LZOpenFile("c:\\myfile.tx", DestStruct, OF_CREATE) 'Copy the files

lResults = LZCopy(hSource, hDest)

'Close the files

LZClose hSource

LZClose hDest

'Check for errors

Select Case lResults

Case LZERROR_BADINHANDLE

MsgBox "LZERROR_BADINHANDLE"

Case LZERROR_BADOUTHANDLE

MsgBox "LZERROR_BADOUTHANDLE"

Case LZERROR_BADVALUE

MsgBox "LZERROR_BADVALUE"

Case LZERROR_GLOBLOCK

MsgBox "LZERROR_GLOBLOCK"

Case LZERROR_PUBLICLOC

MsgBox "LZERROR_PUBLICLOC"

Case LZERROR_READ

MsgBox "LZERROR_READ"

Case LZERROR_UNKNOWNALG

MsgBox "LZERROR_UNKNOWNALG"

Case LZERROR_WRITE

MsgBox "LZERROR_WRITE"

End Select

End Sub

参数表

参数 类型及说明

lpszFile String,欲打开的文件名

lpOf OFSTRUCT,该结构填充的数据包括与本次处理的文件和结果有关的信息

style Long,处理方式标志常数的一种组合。参考OpenFile函数的标志常数表

注解

参考OpenFile函数

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2024/12/23 14:44:04