使用VB6操作WinRAR(VB6源代码)

合集下载

VB解压缩带密码RAR文件的两者方法

VB解压缩带密码RAR文件的两者方法

VB解压缩带密码RAR文件的两者方法在一些批处理任务的应用程序如安装程序中,需要对压缩文件进行解压缩处理。

VB来实现对压缩文件格式,如RAR、Zip等文件的解压缩,总的来说,有以下两种方法:一、采用winrar命令行一般来说,安装好winrar后,在安装目录中,有个名为rar.txt的文件。

其实该文件就是Winrar的控制台(命令行)中文手册。

下面我们一起来学习一下,和解压缩文件有关的命令行。

Winrar命令行的通用格式是:RAR <命令> [ -<开关> ] <压缩文件> [ <@列表文件...> ][ <文件...> ] [ <解压路径\> ]举例来说,<命令>为a时,表示添加文件到压缩文件中,其中需压缩的文件由列表文件指定。

当<命令>为e的时候,就表示解压文件到当前目录。

如果需要将压缩文件解压缩到自定义目录,则通常使用x命令,该命令表示带绝对路径进行解压缩。

-<开关>为-y,表示对于所有询问全部回答是。

如果rar文件包含密码,则需要添加开关为"-p密码字符串",否则不能正常解压缩。

如果要判断是否winrar命令行是否执行成功,可以通过该命令行的返回值来判断。

如果返回值为0,则成功执行。

如果不为0,则执行过程中出现错误。

错误代码rar.txt中有详细定义。

请仔细研读该文件。

在有了上述理论作为基础之后,接下来,我们用VB来实现创建和解压缩一个带密码的压缩文件。

打开VB6,新建一个标准的Exe工程文件,界面设计如下图所示,控件的名称采用默认的名称。

图解压缩界面程序首先要获得Winrar的安装路径,一般来说,安装好了Winrar后,会在注册表的HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentV ersion\App Paths\创建一个winrar.exe的路径,该路径下有一个名为Path的字符串项,该项的值保存的就是Winrar的安装路径。

VB6编程步骤-全部

VB6编程步骤-全部

VB6编程步骤题目要求1.新建工程,在工程中新建2个窗体和1个模块,窗体命名为frmMain和frmConfig,添加Excel操作专用模块。

2.执行菜单命令“工具-选项-编辑器格式”,设置标准文本的字体格式为自己喜欢的格式,执行菜单命令“工具-选项-编辑器”,“要求变量声明”前打勾3.设置工程1的属性,修改启动对象为Sub Main,在module1中添加Sub Main过程,并输入代码:frmMain.Show vbModal。

在frmMain上添加一个退出按钮,设置其合适的大小和字体,双击该按钮,输入“Unload Me”。

4.在frmMain窗体上放置“参数设定”按钮,修改合适的外观属性,双击该按钮,输入代码“frmConfig.showvbmodal”5.参数设定编程方法:(1)在module1模块中,定义保存参数的自定义变量Public Type mSetData ' 自定义数据类型:设置参数,用于保存到磁盘文件中TH As Single ' 温度高限TL As Single ' 温度低限RHH As Single ' 湿度高限RHL As Single ' 湿度低限End TypePublic mAlarm As mSetData ' 用自定义类型mSetData 定义设置参数变量mAlarmPublic sAppPath As String ' 字符串,存放应用程序所在的路径(2)在module1模块中创建一个初始化过程Init,代码如下Sub Init()sAppPath = "E:\软件技术基础\TR" '应用程序路径Open sAppPath & "\Para.a" For Random As #1 Len = Len(mAlarm) ' 打开随机方式访问文件Get #1, 1, mAlarm ' 读取文件内容到变量中Close #1 '关闭文件End Sub在sub Main 中调用Init 过程Sub main()Init ' 初始化,读取原设置参数frmMain.Show vbModal ' 启动主窗体,有模式窗体End Sub(3)设置frmConfig窗体的界面。

VB中利用WinRAR进行文件压缩

VB中利用WinRAR进行文件压缩

VB中利用WinRAR进行文件压缩
王莉梅
【期刊名称】《网迷》
【年(卷),期】2001(000)007
【总页数】2页(P51-52)
【作者】王莉梅
【作者单位】无
【正文语种】中文
【中图分类】TP311.1
【相关文献】
1.在VB+SQL Server 2000系统中利用ADO进行各种查询的实现 [J], 李志云
2.Excel中利用VBA进行学院教务管理研究 [J], 周双恋;刘远芳;陈秀兰
3.利用Winrar进行文件压缩(解压缩)的两点改进 [J], 李伟春
4.利用VB在网刊发布中对全文电子文件进行重命名 [J], 杨海亮;付示威;林清华
5.EXCEL中的VBA在档案整理过程中的应用——利用VBA进行繁琐的文件目录生成 [J], 孙杰; 戴清清; 张春艳; 蔡梦凡; 杨帆; 张筱蓉
因版权原因,仅展示原文概要,查看原文内容请购买。

VB调用WinRAR

VB调用WinRAR

与WinRAR以最快方式压缩ZIP比较,255M的文件Level=0时用时秒大小95.1MLevel=255时用时秒大小91.6MWinRAR最快压缩ZIP 用时秒大小58.6M标准RAR压缩,我看了一下,实在太慢,也就没试了,估计要几分钟才会有结果。

从速度看,基本持平了,这个算法虽然最大压缩能力有限,但感觉设计得很巧妙,每次都基于动态表,使软件可以做得很小巧,资源占用也很少。

非常值得收藏!'测试窗体中的代码Option ExplicitPrivate WithEvents ObjZip As ClassZipPrivate BgTime As SinglePrivate Sub Command1_Click()BgTime = Timer= False= FalseWith ObjZip.InputFileName =.OutputFileName =.IsCompress = True.CompressLevel = Val.BeginProcssEnd With= Round(Timer - BgTime, 2) & "秒"= True= TrueEnd SubPrivate Sub Command2_Click()BgTime = Timer= False= FalseWith ObjZip.InputFileName =.OutputFileName =.IsCompress = False.BeginProcssEnd WithLabel1 = Round(Timer - BgTime, 2) & "秒"= True= TrueEnd SubPrivate Sub Command3_Click()= TrueEnd SubPrivate Sub Form_Load()Set ObjZip = New ClassZip= "压缩"= "解压"= "中断"End SubPrivate Sub Form_Unload(Cancel As Integer)Set ObjZip = NothingEnd SubPrivate Sub ObjZip_FileProgress(sngPercentage As Single) Label1 = Int(sngPercentage * 100) & "%"End SubPrivate Sub ObjZip_ProcssError(ErrorDescription As String) MsgBox ErrorDescriptionEnd Sub'ClassZip类中的声明与属性、方法、事件Option ExplicitPublic Event FileProgress(sngPercentage As Single)Public Event ProcssError(ErrorDescription As String) Private Type FileHeaderHeaderTag As String * 3HeaderSize As IntegerFlag As ByteFileLength As LongVersion As IntegerEnd TypePrivate mintCompressLevel As LongPrivate m_bEnableProcss As BooleanPrivate m_bCompress As BooleanPrivate m_strInputFileName As StringPrivate m_strOutputFileName As StringPrivate Const mcintWindowSize As Integer = &H1000 Private Const mcintMaxMatchLen As Integer = 18Private Const mcintMinMatchLen As Integer = 3Private Const mcintNull As Long = &H1000Private Const mcstrSignature As String = "FMZ"Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (pDest As Any, pSou rce As Any, ByVal dwLength As Long)Public Sub BeginProcss()If m_bCompress ThenCompressElseDecompressEnd IfEnd SubPrivate Function LastError(ErrNo As Integer) As StringSelect Case ErrNoCase 1LastError = "待压缩文件未设置或不存在"Case 2LastError = "待压缩文件长度太小"Case 3LastError = "待压缩文件已经过压缩"Case 4LastError = "待解压文件未设置或不存在"Case 5LastError = "待解压文件格式不对或为本软件不能认别的高版本软件所压缩"Case 254LastError = "用户取消了操作"Case 255LastError = "未知错误"End SelectEnd FunctionPublic Property Get CompressLevel() As IntegerCompressLevel = mintCompressLevel \ 16End PropertyPublic Property Let CompressLevel(ByVal intValue As Integer)mintCompressLevel = intValue * 16If mintCompressLevel < 0 Then mintCompressLevel = 0End PropertyPublic Property Get IsCompress() As BooleanIsCompress = m_bCompressEnd PropertyPublic Property Let IsCompress(ByVal bValue As Boolean)m_bCompress = bValueEnd PropertyPublic Property Let CancelProcss(ByVal bValue As Boolean)m_bEnableProcss = Not bV alueEnd PropertyPublic Property Get InputFileName() As StringInputFileName = m_strInputFileNameEnd PropertyPublic Property Get OutputFileName() As StringOutputFileName = m_strOutputFileNameEnd PropertyPublic Property Let OutputFileName(ByVal strValue As String)m_strOutputFileName = strValueEnd PropertyPublic Property Let InputFileName(ByVal strValue As String)m_strInputFileName = strValueEnd PropertyPrivate Sub Class_Terminate()m_bEnableProcss = FalseEnd SubPrivate Sub Compress()Dim lngTemp As Long, intCount As IntegerDim intBufferLocation As IntegerDim intMaxLen As IntegerDim intNext As IntegerDim intPrev As IntegerDim intMatchPos As IntegerDim intMatchLen As IntegerDim intInputFile As IntegerDim intOutputFile As IntegerDim aintWindowNext(mcintWindowSize + 1 + mcintWindowSize) As IntegerDim aintWindowPrev(mcintWindowSize + 1) As IntegerDim intByteCodeWritten As LongDim intBitCount As IntegerDim abytWindow(mcintWindowSize + mcintMaxMatchLen) As ByteDim udtFileH As FileHeaderDim strOutTmpFile As StringDim lngBytesRead As LongDim lngFileLength As LongDim lngCurWritten As LongDim lngInBufLen As Long, abytInputBuffer() As Byte, abytOutputBuffer() As Byte Dim lngOutBufLen As Long, lngInPos As Long, lngOutPos As LongDim intErrNo As IntegerOn Error GoTo PROC_ERRm_bEnableProcss = TrueIf Len(Dir(m_strInputFileName)) = 0 Or Len(m_strInputFileName) = 0 Then intErrNo = 1: GoTo PROC_ERRIf Len(m_strOutputFileName) = 0 Then m_strOutputFileName = m_strInputFileNamestrOutTmpFile = m_strOutputFileName & ".tmp"If Len(Dir(strOutTmpFile)) > 0 Then Kill strOutTmpFileIf FileLen(m_strInputFileName) < 100 Then intErrNo = 2: GoTo PROC_ERRintInputFile = FreeFileOpen m_strInputFileName For Binary Access Read As intInputFileGet intInputFile, , udtFileHSeek #intInputFile, 1If = mcstrSignature Then intErrNo = 3: GoTo PROC_ERRintOutputFile = FreeFileOpen strOutTmpFile For Binary As intOutputFileFor intCount = 0 To mcintWindowSizeaintWindowPrev(intCount) = mcintNullabytWindow(intCount) = &H20NextCopyMemory aintWindowNext(0), aintWindowPrev(0), (mcintWindowSize + 1) * 2CopyMemory aintWindowNext(mcintWindowSize + 1), aintWindowPrev(0), mcintWindowSize * 2CopyMemory abytWindow(mcintWindowSize + 1), abytWindow(0), mcintMaxMatchLen - 1intByteCodeWritten = 1lngFileLength = LOF(intInputFile)lngInBufLen = &HA000&lngOutBufLen = &HA000&If lngInBufLen > lngFileLength Then lngInBufLen = lngFileLengthReDim abytInputBuffer(lngInBufLen - 1)ReDim abytOutputBuffer(lngOutBufLen + 17)With udtFileH.HeaderSize = Len(udtFileH)lngCurWritten = .HeaderSize + 1.HeaderTag = mcstrSignature.FileLength = lngFileLength.Version =.Flag = 0End WithintMaxLen = mcintMaxMatchLenlngBytesRead = mcintMaxMatchLenlngInPos = mcintMaxMatchLenintBitCount = 1Put intOutputFile, , udtFileHGet intInputFile, , abytInputBufferCopyMemory abytWindow(0), abytInputBuffer(0), mcintMaxMatchLenCopyMemory abytWindow(mcintWindowSize), abytInputBuffer(0), mcintMaxMatchLenDo While intMaxLenintMatchPos = 0intMatchLen = 0intPrev = aintWindowNext(((&H100& * abytWindow(intBufferLocation + 1) + abytWindow(int BufferLocation)) And &HFFF) + mcintWindowSize + 1)intCount = 0Do Until intCount > mintCompressLevel Or intPrev = mcintNullintNext = 0Do While (abytWindow(intPrev + intNext) = abytWindow(intBufferLocation + intNext)) And int Next < mcintMaxMatchLenintNext = intNext + 1LoopIf intNext > intMatchLen ThenintMatchLen = intNextintMatchPos = intPrevIf intNext = mcintMaxMatchLen ThenaintWindowNext(aintWindowPrev(intPrev)) = aintWindowNext(intPrev)aintWindowPrev(aintWindowNext(intPrev)) = aintWindowPrev(intPrev)aintWindowNext(intPrev) = mcintNullaintWindowPrev(intPrev) = mcintNullExit DoEnd IfEnd IfintPrev = aintWindowNext(intPrev)intCount = intCount + 1LoopIf intBitCount And &H100 ThenlngOutPos = intByteCodeWrittenIf intByteCodeWritten > lngOutBufLen ThenPut intOutputFile, lngCurWritten, abytOutputBufferDoEventsIf m_bEnableProcss = False Then intErrNo = 254: GoTo PROC_ERRlngCurWritten = lngCurWritten + intByteCodeWrittenlngOutPos = 0End IfintByteCodeWritten = lngOutPos + 1intBitCount = 1abytOutputBuffer(lngOutPos) = 0End IfIf intMatchLen < mcintMinMatchLen ThenintMatchLen = 1abytOutputBuffer(intByteCodeWritten) = abytWindow(intBufferLocation)abytOutputBuffer(lngOutPos) = abytOutputBuffer(lngOutPos) Or intBitCountEnd IfIf intMatchLen > 1 ThenIf intMatchLen > intMaxLen Then intMatchLen = intMaxLenabytOutputBuffer(intByteCodeWritten) = intMatchPos And &HFFintByteCodeWritten = intByteCodeWritten + 1abytOutputBuffer(intByteCodeWritten) = (((intMatchPos \ 16) And &HF0) Or intMatchLen - mci ntMinMatchLen) And &HFFEnd IfintByteCodeWritten = intByteCodeWritten + 1intBitCount = intBitCount * 2Do While intMatchLenintPrev = intBufferLocation + mcintMaxMatchLenintNext = intPrev And &HFFFIf aintWindowPrev(intNext) <> mcintNull ThenaintWindowNext(aintWindowPrev(intNext)) = aintWindowNext(intNext)aintWindowPrev(aintWindowNext(intNext)) = aintWindowPrev(intNext)aintWindowNext(intNext) = mcintNullaintWindowPrev(intNext) = mcintNullEnd IfIf lngInPos < lngInBufLen ThenabytWindow(intNext) = abytInputBuffer(lngInPos)If intPrev >= mcintWindowSize Then abytWindow(intPrev) = abytInputBuffer(lngInPos)lngBytesRead = lngBytesRead + 1lngInPos = lngInPos + 1If lngInPos >= lngInBufLen ThenIf lngFileLength > lngBytesRead ThenIf lngInBufLen > lngFileLength - lngBytesRead ThenlngInBufLen = lngFileLength - lngBytesReadReDim abytInputBuffer(lngInBufLen - 1)End IfGet intInputFile, , abytInputBufferlngInPos = 0RaiseEvent FileProgress(lngBytesRead / lngFileLength)DoEventsIf m_bEnableProcss = False Then intErrNo = 254: GoTo PROC_ERREnd IfEnd IfEnd IfintPrev = ((&H100& * abytWindow(intBufferLocation + 1) + abytWindow(intBufferLocation)) A nd &HFFF) + mcintWindowSize + 1intNext = aintWindowNext(intPrev)aintWindowPrev(intBufferLocation) = intPrevaintWindowNext(intBufferLocation) = intNextaintWindowNext(intPrev) = intBufferLocationIf intNext <> mcintNull Then aintWindowPrev(intNext) = intBufferLocationintBufferLocation = (intBufferLocation + 1) And &HFFFintMatchLen = intMatchLen - 1LoopIf lngInPos >= lngInBufLen Then intMaxLen = intMaxLen - 1LoopIf intByteCodeWritten > 0 ThenReDim Preserve abytOutputBuffer(intByteCodeWritten - 1)Put intOutputFile, lngCurWritten, abytOutputBufferEnd IfClose intInputFileClose intOutputFileIf Len(Dir(m_strOutputFileName)) > 0 Then Kill m_strOutputFileNameName strOutTmpFile As m_strOutputFileNameRaiseEvent FileProgress(1)Exit SubPROC_ERR:Close intOutputFileClose intInputFileIf Len(Dir(strOutTmpFile)) > 0 And Len(strOutTmpFile) > 0 Then Kill strOutTmpFileIf intErrNo = 0 Then intErrNo = 255RaiseEvent ProcssError(LastError(intErrNo))End SubPrivate Sub Decompress()Dim intTemp As IntegerDim intBufferLocation As IntegerDim intLength As IntegerDim bytHiByte As IntegerDim bytLoByte As IntegerDim intWindowPosition As IntegerDim lngFlags As LongDim intInputFile As IntegerDim intOutputFile As IntegerDim abytWindow(mcintWindowSize + mcintMaxMatchLen) As ByteDim strOutTmpFile As StringDim lngBytesRead As LongDim lngBytesWritten As LongDim lngFileLength As LongDim lngOriginalFileLen As LongDim lngInBufLen As Long, abytInBuf() As Byte, abytOutBuf() As ByteDim lngOutBufLen As Long, lngInPos As Long, lngOutPos As LongDim udtFileH As FileHeaderDim intErrNo As IntegerOn Error GoTo PROC_ERRm_bEnableProcss = TrueIf Len(Dir(m_strInputFileName)) = 0 Or Len(m_strInputFileName) = 0 Then intErrNo = 4: GoTo PROC_ERRIf Len(m_strOutputFileName) = 0 Then m_strOutputFileName = m_strInputFileNamestrOutTmpFile = m_strOutputFileName & ".tmp"If Len(Dir(strOutTmpFile)) > 0 Then Kill strOutTmpFileintInputFile = FreeFileOpen m_strInputFileName For Binary Access Read As intInputFilelngFileLength = LOF(intInputFile)Get intInputFile, , udtFileHIf = mcstrSignature And <= ThenSeek #intInputFile, + 1intOutputFile = FreeFileOpen strOutTmpFile For Binary As intOutputFilelngOriginalFileLen =lngFileLength = lngFileLength -lngInBufLen = &H20000lngOutBufLen = &H20000If lngInBufLen > lngFileLength Then lngInBufLen = lngFileLengthReDim abytInBuf(lngInBufLen - 1)ReDim abytOutBuf(lngOutBufLen - 1)Get intInputFile, , abytInBufDo While lngBytesWritten < lngOriginalFileLenlngFlags = lngFlags \ 2If (lngFlags And &H100) = 0 ThenlngFlags = &HFF00& Or abytInBuf(lngInPos)lngBytesRead = lngBytesRead + 1lngInPos = lngInPos + 1If lngInPos >= lngInBufLen ThenIf lngFileLength > lngBytesRead ThenIf lngInBufLen > lngFileLength - lngBytesRead ThenlngInBufLen = lngFileLength - lngBytesReadReDim abytInBuf(lngInBufLen - 1)End IfGet intInputFile, , abytInBufDoEventsIf m_bEnableProcss = False Then intErrNo = 254: GoTo PROC_ERR lngInPos = 0End IfEnd IfEnd IfIf (lngFlags And 1) ThenabytWindow(intWindowPosition) = abytInBuf(lngInPos)abytOutBuf(lngOutPos) = abytInBuf(lngInPos)lngBytesRead = lngBytesRead + 1lngInPos = lngInPos + 1lngBytesWritten = lngBytesWritten + 1lngOutPos = lngOutPos + 1intWindowPosition = (intWindowPosition + 1) And &HFFFIf lngInPos >= lngInBufLen ThenIf lngFileLength > lngBytesRead ThenIf lngInBufLen > lngFileLength - lngBytesRead ThenlngInBufLen = lngFileLength - lngBytesReadReDim abytInBuf(lngInBufLen - 1)End IfGet intInputFile, , abytInBufDoEventsIf m_bEnableProcss = False Then intErrNo = 254: GoTo PROC_ERR lngInPos = 0End IfEnd IfIf lngOutPos >= lngOutBufLen ThenPut intOutputFile, , abytOutBuflngOutPos = 0RaiseEvent FileProgress(lngBytesWritten / lngOriginalFileLen)DoEventsIf m_bEnableProcss = False Then intErrNo = 254: GoTo PROC_ERR End IfElsebytHiByte = abytInBuf(lngInPos)lngBytesRead = lngBytesRead + 1lngInPos = lngInPos + 1If lngInPos >= lngInBufLen ThenIf lngFileLength > lngBytesRead ThenIf lngInBufLen > lngFileLength - lngBytesRead ThenlngInBufLen = lngFileLength - lngBytesReadReDim abytInBuf(lngInBufLen - 1)End IfGet intInputFile, , abytInBufDoEventsIf m_bEnableProcss = False Then intErrNo = 254: GoTo PROC_ERRlngInPos = 0End IfEnd IfbytLoByte = abytInBuf(lngInPos)intBufferLocation = ((bytLoByte And &HF0) * 16 + bytHiByte) And &HFFF intLength = (bytLoByte And &HF) + mcintMinMatchLenlngBytesRead = lngBytesRead + 1lngInPos = lngInPos + 1If lngInPos >= lngInBufLen ThenIf lngFileLength > lngBytesRead ThenIf lngInBufLen > lngFileLength - lngBytesRead ThenlngInBufLen = lngFileLength - lngBytesReadReDim abytInBuf(lngInBufLen - 1)End IfGet intInputFile, , abytInBufDoEventsIf m_bEnableProcss = False Then intErrNo = 254: GoTo PROC_ERRlngInPos = 0End IfEnd IfintTemp = intBufferLocation + intLengthDo While intBufferLocation < intTempabytOutBuf(lngOutPos) = abytWindow((intBufferLocation) And &HFFF)abytWindow(intWindowPosition) = abytOutBuf(lngOutPos)intBufferLocation = intBufferLocation + 1lngBytesWritten = lngBytesWritten + 1intWindowPosition = (intWindowPosition + 1) And &HFFFlngOutPos = lngOutPos + 1If lngOutPos >= lngOutBufLen ThenPut intOutputFile, , abytOutBuflngOutPos = 0RaiseEvent FileProgress(lngBytesWritten / lngOriginalFileLen)DoEventsIf m_bEnableProcss = False Then intErrNo = 254: GoTo PROC_ERREnd IfLoopEnd IfLoopIf lngOutPos > 0 ThenReDim Preserve abytOutBuf(lngOutPos - 1)Put intOutputFile, , abytOutBufEnd IfClose intOutputFileElseintErrNo = 5GoTo PROC_ERREnd IfClose intInputFileIf Len(Dir(m_strOutputFileName)) > 0 Then Kill m_strOutputFileNameName strOutTmpFile As m_strOutputFileNameRaiseEvent FileProgress(1)Exit SubPROC_ERR:Close intOutputFileClose intInputFileIf Len(Dir(strOutTmpFile)) > 0 And Len(strOutTmpFile) > 0 Then Kill strOutTmpFileIf intErrNo = 0 Then intErrNo = 255RaiseEvent ProcssError(LastError(intErrNo))End Sub'ClassZip类中的声明与属性、方法、事件Option ExplicitPublic Event FileProgress(sngPercentage As Single)Public Event ProcssError(ErrorDescription As String)Private Type FileHeaderHeaderTag As String * 3HeaderSize As IntegerFlag As ByteFileLength As LongVersion As IntegerEnd TypePrivate mintCompressLevel As LongPrivate m_bEnableProcss As BooleanPrivate m_bCompress As BooleanPrivate m_strInputFileName As StringPrivate m_strOutputFileName As StringPrivate Const mcintWindowSize As Integer = &H1000Private Const mcintMaxMatchLen As Integer = 18Private Const mcintMinMatchLen As Integer = 3Private Const mcintNull As Long = &H1000Private Const mcstrSignature As String = "FMZ"Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (pDest As Any, pSou rce As Any, ByVal dwLength As Long)Public Sub BeginProcss()If m_bCompress ThenCompressElseDecompressEnd IfEnd SubPrivate Function LastError(ErrNo As Integer) As StringSelect Case ErrNoCase 1LastError = "待压缩文件未设置或不存在"Case 2LastError = "待压缩文件长度太小"Case 3LastError = "待压缩文件已经过压缩"Case 4LastError = "待解压文件未设置或不存在"Case 5LastError = "待解压文件格式不对或为本软件不能认别的高版本软件所压缩" Case 254LastError = "用户取消了操作"Case 255LastError = "未知错误"End SelectEnd FunctionPublic Property Get CompressLevel() As IntegerCompressLevel = mintCompressLevel \ 16End PropertyPublic Property Let CompressLevel(ByVal intValue As Integer)mintCompressLevel = intValue * 16If mintCompressLevel < 0 Then mintCompressLevel = 0End PropertyPublic Property Get IsCompress() As BooleanIsCompress = m_bCompressEnd PropertyPublic Property Let IsCompress(ByVal bValue As Boolean)m_bCompress = bValueEnd PropertyPublic Property Let CancelProcss(ByVal bValue As Boolean)m_bEnableProcss = Not bV alueEnd PropertyPublic Property Get InputFileName() As StringInputFileName = m_strInputFileNameEnd PropertyPublic Property Get OutputFileName() As StringOutputFileName = m_strOutputFileNameEnd PropertyPublic Property Let OutputFileName(ByVal strValue As String) m_strOutputFileName = strValueEnd PropertyPublic Property Let InputFileName(ByVal strValue As String) m_strInputFileName = strValueEnd PropertyPrivate Sub Class_Terminate()m_bEnableProcss = FalseEnd SubPrivate Sub Form_Load()Set ObjZip = New ClassZip= "压缩"= "解压"= "中断"End SubPrivate Sub Form_Unload(Cancel As Integer)Set ObjZip = NothingEnd SubPrivate Sub ObjZip_FileProgress(sngPercentage As Single)Label1 = Int(sngPercentage * 100) & "%"End SubPrivate Sub ObjZip_ProcssError(ErrorDescription As String) MsgBox ErrorDescriptionEnd Sub'ClassZip类中的声明与属性、方法、事件Option ExplicitPublic Event FileProgress(sngPercentage As Single)Public Event ProcssError(ErrorDescription As String)Private Type FileHeaderHeaderTag As String * 3HeaderSize As IntegerFlag As ByteFileLength As LongVersion As IntegerEnd TypePrivate mintCompressLevel As LongPrivate m_bEnableProcss As BooleanPrivate m_bCompress As BooleanPrivate m_strInputFileName As StringPrivate m_strOutputFileName As StringPrivate Const mcintWindowSize As Integer = &H1000Private Const mcintMaxMatchLen As Integer = 18Private Const mcintMinMatchLen As Integer = 3Private Const mcintNull As Long = &H1000Private Const mcstrSignature As String = "FMZ"Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (pDest As Any, pSou rce As Any, ByVal dwLength As Long)Public Sub BeginProcss()If m_bCompress ThenCompressElseDecompressEnd IfEnd SubPrivate Function LastError(ErrNo As Integer) As StringSelect Case ErrNoCase 1LastError = "待压缩文件未设置或不存在"Case 2LastError = "待压缩文件长度太小"Case 3LastError = "待压缩文件已经过压缩"Case 4LastError = "待解压文件未设置或不存在"Case 5LastError = "待解压文件格式不对或为本软件不能认别的高版本软件所压缩"Case 254LastError = "用户取消了操作"Case 255LastError = "未知错误"End SelectEnd FunctionPublic Property Get CompressLevel() As IntegerCompressLevel = mintCompressLevel \ 16End PropertyPublic Property Let CompressLevel(ByVal intValue As Integer)mintCompressLevel = intValue * 16If mintCompressLevel < 0 Then mintCompressLevel = 0End PropertyPublic Property Get IsCompress() As BooleanIsCompress = m_bCompressEnd PropertyPublic Property Let IsCompress(ByVal bValue As Boolean)m_bCompress = bValueEnd PropertyPublic Property Let CancelProcss(ByVal bValue As Boolean) m_bEnableProcss = Not bV alueEnd PropertyPublic Property Get InputFileName() As StringInputFileName = m_strInputFileNameEnd PropertyPublic Property Get OutputFileName() As StringOutputFileName = m_strOutputFileNameEnd PropertyPublic Property Let OutputFileName(ByVal strValue As String) m_strOutputFileName = strValueEnd PropertyPublic Property Let InputFileName(ByVal strValue As String) m_strInputFileName = strValueEnd PropertyPrivate Sub Class_Terminate()m_bEnableProcss = FalseEnd Sub。

VisualBasic6.0(VB6.0)安装教程详解

VisualBasic6.0(VB6.0)安装教程详解

VisualBasic6.0(VB6.0)安装教程详解visual basic 6.0中⽂版是⼀种由微软公司开发的包含协助开发环境的事件驱动编程语⾔,它源⾃于BASIC编程语⾔,拥有图形⽤户界⾯(GUI)和快速应⽤程序开发(RAD)系统,可以轻易的使⽤DAO、RDO、ADO连接数据库,或者轻松的创建ActiveX控件。

VB 6.0中⽂企业版免费下载(206M)类型:编译⼯具⼤⼩:206MB语⾔:简体中⽂时间:2020-01-08查看详情特别提⽰:安装此软件的时候最好退出360杀毒软件(包括360安全卫⼠,电脑管家等,如果电脑上有这些软件的话),因为现如今的360杀毒软件直接会对VB6.0软件误报,这样的话就可能会在安装过程中被误报阻⽌⽽导致安装失败,或者是安装后缺乏很多必须的组件(其它的杀毒软件或安全卫⼠之类的没关系)!安装过程介绍:将下载的⽂件解压(电脑上需要先安装了压缩软件),然后打开解压后的⽂件夹,如果⾥⾯是⼀个ISO镜像⽂件,则继续解压,如图所⽰:(注意):不能直接双击打开,或者是使⽤虚拟光驱软件加载打开此ISO镜像⽂件,因为此软件在安装了以后,还需要重启电脑,然后进⾏设置,⽽直接双击打开(这也是使⽤虚拟光驱打开的⼀种⽅式)或者是使⽤虚拟光驱软件加载打开的⽂件,通常在重启电脑了以后不会被加载,这样就会导致不会再出现VB6.0的安装对话框,可能会导致安装失败。

然后再打开解压后的⽂件夹,双击运⾏⾥⾯的⽂件SETUP.EXE,即可开始安装,如图所⽰:(注意)如果你使⽤的电脑是Windows7、Windows8(8.1)或者是Windows10操作系统,则可能会出现“程序兼容性”的提⽰,此时直接点击“运⾏程序”即可,不需要进⾏其它的设置,如图所⽰:然后在打开的“安装向导”当中点击“下⼀步”:选择“接受协议”,然后点击“下⼀步”:输⼊ID号“111-1111111”,然后输⼊姓名(可以随意填写),公司名称处可以不填,然后点击“下⼀步”:点击“下⼀步”:点击“下⼀步”:点击“继续”:点击“确定”:然后进⼊搜索已安装组件的过程(注:此过程有可能会⽐较漫长,有的时候看起来像死机⼀样,但不需要进⾏任何操作,等待就可以了):此时如果遇到⼀个“发现了旧版本的Visual SourceSafe”的提⽰,点击“是”和“否”都可以(因为下⾯会取消这个组件的安装,因为如果安装了这个组件,则在此电脑的VB6.0上写的代码,拿到其它的电脑上以后就不能修改了):然后点击“⾃定义安装”,此处选择⾃定义安装的⽬的是为了取消安装那个VSS组件,要不然选择“典型安装”后,会同时安装了VSS组件,这样以后每⼀次打开从其它地⽅拿来的系统源代码时都会有⼀个英⽂提⽰,挺烦⼈的。

在VB6.0中调用和操作MATLAB

在VB6.0中调用和操作MATLAB

收 稿 日期 : 初稿 :0 1 1 7 修 订稿 :0 2— 3 8 2 0 —1 —2 ; 2 0 0 —0 作 者简 介 : 郑君 杰( 9 7 ) 男 , 宁大 连人 . 17一 . 辽 信号 与信 息 处理 专 业 硕 士研究 生, 研究 方向 为图像处 理. 模式识 别.
OX文 件 .在 程 序 中 加 入 Acie 部 件 后 将 成 为 开 C t X v 它
郑君杰, 黄
峰( 解放 军理 工 大 学 气 象学 院 研 究 生 1 8队, 江苏 南京 2 10 ) 1 · e HUANG F n ( ieainAr ies yo ce c n n ie r g N n n S 2 1 0 , hn ) i e g L b rt my Unv r t f i ea d E gn ei , a j gJ 1 1 1 C ia o i S n n i
使 用 的 编 程 接 口, 对 广 大 的 VB 程 序 员 来 说 是 一 个 这 很 大 的 不 便 . 本 文 介 绍 了 通 过 A t e 技 术 在 VB . ci X v 60 中调 用 和 操 作 Mal t b的 方 法 , 现 了 Malb和 v 的 a 实 t a B
中图分 类号 : 3 9 TP 1
文 献标识 码 : A
1 引 言 Vi a B s ( 称 VB 是 微 软 公 司 推 出 的 可 视 化 s l ai 简 u c )
混 合 编 程 , 分 发 挥 了 两 者 各 自的 优 势 . 充 2 基本 原理 2 1 A t e 的 基 本 概 念 . ci X v 由 于无 法 在 v 中直 接 调 用 Mal , 者 利 用 A . B tb 笔 a c t e 技 术 解 决 了 这 个 问 题 . 所 谓 的 Acie 是 一 种 开 iX v t X v 放 式 的 标 准 . 允 许 直 用 程 序 或 部 件 控 制 另 一 个 应 用 它 程 序 或 部 件 的 运 行 . A t e 部 件 是 M i oot 司 提 ci X v c sf 公 r

使用VB6.0制作软件安装包的详细方法步骤

使用VB6.0制作软件安装包的详细方法步骤

使用VB6.0制作软件安装包的详细方法步骤使用VB6.0制作软件安装包的详细方法步骤使用VB6.0打开需要打包的工程,选择菜单栏中的“外接程序”->“外接程序管理器”,在对话框中选择“打包和展开向导”,在“加载行为”选项组中选中“加载/卸载”复选框,然后单击确定按钮。

然后选择菜单栏中的“外接程序”,发现比刚才多了一个“打包和展开向导”,选择它并在对话框中单击打包按钮,后边的事情就简单多了(向导一般做的都很容易的)。

打包向导过程说明:1.选择安装包保存位置默认情况下安装包会放到工程文件目录下的“包”目录。

可以根据需要进行修改。

单击“下一步”。

2.选择包含文件“包含文件”对话框已经自动找出了工程中应用的控件、DLL等文件,检查一下有没有遗漏的文件。

如果有,可以通过“添加”按钮增加用户需要的文件,例如帮助文件Help.chm。

3.选择打包文件类型单击“下一步”显示压缩文件选项对话框。

现在的安装程序一般都用光盘作为载体,选中单个压缩文件即可。

4.设置安装程序标题单击“下一步”显示“安装程序标题”对话框,输入安装程序标题,它会显示在安装背景上。

5.创建启动菜单项单击“下一步”显示“启动菜单项”对话框。

在这里创建“开始菜单”中显示的项目,默认只有运行程序。

6.指定安装位置单击“下一步”显示“安装位置”对话框,在这里设置安装包中的文件具体的安装目录,同样是用宏来指定还可以设置子目录,安装时会自动创建不存在的子目录。

7.共享文件单击“下一步”显示“共享文件”对话框选择可能被多个文件使用的文件如ActiveX控件,这样当程序卸载时,不会把共享文件也删除。

另外,还可以用第三方打包工具。

“打包和展开向导”虽然功能不够强大但简单易用,针对一般的应用已经足够了。

INI文件读取模块(VB6源代码)

INI文件读取模块(VB6源代码)
Option Explicit
Private strInI As String
'// windows Api函数声明
Private Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" _
'设置INI文件的路径
strInI = New_IniPath
End Property
Public Property Geபைடு நூலகம் IniFilePath() As String
'读回INI文件的路径
IniFilePath = strInI '把INIFile赋给strInI
End Property
ByVal lpFileName As String) As Long
'GetPrivateProfileString 为初始化文件中指定的条目取得字串
'lpApplicationName - String,欲在其中查找条目的小节名称。这个字串不区分大小写。如设为vbNullString,就在lpReturnedString缓冲区内装载这个ini文件所有小节的列表
End Sub
Public Function GetINIFile(strSection As String, strKey As String, Optional vDefault As String) As String
Dim strTmp As String ' * 100
Dim lngRet As String
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

使用Visual Basic 6.0 控制WinRAR进行压缩或解压等操作(1)命令行语法:--------------------------------------------------------------------------------从命令行也可以运行WinRAR 命令,常规的命令行语法描述如下:WinRAR <命令> -<开关1> -<开关N><压缩文件><文件...><@列表文件...><解压路径\>a) 如果未指定文件或是列表文件时,WinRAR 将会以缺省的*.* 运行全部的文件;b) 如果未指定压缩文件扩展名时,WinRAR 将会使用在压缩配置中选定的默认压缩文件格式。

但你可以指定.RAR 或.ZIP 扩展名来替换它们;c) 在命令行所输入的开关会替换相同的配置设置值;d) 在命令c 、e、s、t、rr、k 和x 可在压缩文件名中使用通配符。

如此可以用单个的命令来进行超过一个以上的压缩文件,除此之外,如果你指定-r 开关于这些命令时,它们将会搜索在子文件夹中的压缩文件;e) 某些命令和开关只应用在RAR 压缩文件,有些则在RAR 和ZIP 都可使用,而某些则可应用在全部的压缩文件格式。

这一些都得看压缩文件格式所提供的特性而定;f) 命令和开关的大小写是相同意思的,你可以用大写或者小写来下命令均可;g)你可以在命令行中同时指定普通的文件名和列表文件名;h)解压路径只与命令e 和x ,搭配使用。

指出解压文件添加的位置。

如果文件夹不存在时,会自动创建。

(2)字母命令列表(3)详解各个命令:--------------------------------------------------------------------------------命令 A - 添加文件到压缩文件添加指定的文件和文件夹到压缩文件中。

此命令行等同于添加。

注意: 因为分卷压缩文件修改是禁用的,此命令无法应用来更新分卷压缩文件,只用于创建时。

例子:1.从当前文件夹添加全部*.hlp文件到压缩文件help.rar中WinRAR a help *.hlp2.从当前文件夹和子文件夹压缩全部文件成为362000 字节大小、固实的、分卷自解压文件save.part1.exe,save.part2.rar,save.part3.rar 等,并在每一个分卷中添加恢复记录WinRAR a -r -v362 -s -sfx -rr save因为未指定文件名,全部文件(*) 将会被添加。

3.作为一个特别的例外,如果目录名被作为参数指定并且目录名不包含文件掩码和以反斜线结尾,即使没有指定开关-r ,目录和子目录的所有内容都会被添加到压缩文件中。

下面的命令将会把文件夹Bitmaps 中全部的文件添加到RAR 压缩文件Pictures 中: WinRAR a Pictures.rar Bitmaps4.如果文件夹名包含文件掩码或以反斜线结尾,应用普通规则,你需要指定开关-r 处理它的子文件夹。

下面的命令将会把文件夹Bitmaps 中除了子文件夹外全部的文件添加,因为没有指定开关-r:WinRAR a Pictures.rar Bitmaps\*命令 C - 添加压缩文件注释--------------------------------------------------------------------------------命令 C - 添加压缩文件注释此命令允许在压缩文件中添加注释。

RAR 压缩文件的最大注释长度是62000 字节,而ZIP 压缩文件则为32768 字节。

添加压缩文件注释也可以通过使用压缩文件管理命令添加压缩文件注释。

因为分卷压缩文件修改是禁用的,所以注释无法应用在分卷压缩。

当创建分卷压缩时,你可以使用开关-z<文件>来添加注释到分卷压缩。

例子:a) 添加注释到压缩文件distrib.rarWinRAR c distrib.rarb) 从文件添加注释可以使用-z<文件>开关。

WinRAR c -zinfo.txt dummy--------------------------------------------------------------------------------命令CH - 改变压缩文件参数此命令能和大多数压缩文件变量开关一起使用修改压缩文件参数。

对于象-av, -cl, -cu, -tl, 等没有专门命令的开关特别方便。

它不能重新压缩、解密或加密压缩文件数据,它不能整合或创建卷。

如果不和其它开关一起使用,'ch' 命令仅复制压缩文件数据而不修改它。

例如:设置压缩文件时间为最新的文件WinRAR ch -tlfiles.rar--------------------------------------------------------------------------------命令CV - 转换压缩文件此命令提供命令行界面的WinRAR 转换压缩文件格式。

你可以让它和开关-y 组合跳过“转换压缩文件”对话框并使用默认参数开始操作。

使用在“转换压缩文件”的“保存”按钮来改变默认参数。

例如:使用默认转换参数转换c:\files 中所有的ZIP 压缩文件WinRAR cv -y c:\files\*.zip--------------------------------------------------------------------------------命令CW - 写压缩文件注释到指定文件此命令允许保存一个压缩文件的注释到文件。

输出文件的格式依赖于-sc开关。

例子:a) 存储压缩文件arc 的注释到ASCII 文件comment.txtWinRAR cw arc comment.txtb) 存储压缩文件arc 的注释到Unicode文件unicode.txtWinRAR cw -scuc arc unicode.txt--------------------------------------------------------------------------------命令 D - 从压缩文件删除文件从压缩文件删除指定的文件和文件夹。

此命令行命令相当于压缩文件管理命令删除。

注意:1) 如果从压缩文件删除全部的文件时,空白的压缩文件将会被删除。

2) 因为分卷压缩文件修改是禁用的,此命令无法应用于分卷压缩。

例子:从压缩文件dummy 删除全部的*.dmy文件WinRAR d dummy *.dmy--------------------------------------------------------------------------------命令 E - 从压缩文件解压压缩,忽略路径忽略路径解压压缩的文件到当前或指定的文件夹。

此命令行对应的是压缩文件管理命令解压到指定文件夹并在解压路径和选项对话框“不解压路径”的选项是启用时。

例子:在当前文件夹,从全部的RAR 压缩文件解压所有的*.doc 文件到当前文件夹WinRAR e *.rar *.doc--------------------------------------------------------------------------------命令 F - 整理压缩文件内的文件只有在压缩文件中的文件比添加的还旧时才更新。

此命令不会把新文件添加到压缩文件中。

命令行等同于添加到压缩文件并且在压缩文件名和参数对话框选择了“只刷新已存在的文件”的更新模式。

因为分卷压缩文件修改是禁用的,所以此命令无法应用在分卷压缩。

另请参阅: 命令A - 添加文件到压缩文件--------------------------------------------------------------------------------命令I[i|c|h|t]=<字符串> - 在压缩文件中查找字符串在压缩文件中查找字符串。

支持下列参数:i - 不区分大小写查找( 默认);c - 区分大小写查找;h - 十六进制查找;t - 使用ANSI, Unicode 和OEM 字符表;如果没有指定参数,它可以使用简单的命令行语法i<字符串>代替i=<字符串>它还允许和其他参数一起指定‘t’变量,例如,ict=字符串,使用上述所有字符表执行区分大小写的查找。

由于技术限制,现在WinRAR 不支持在ACE 和7Z 压缩文件格式中查找。

例子:1)WinRAR "ic=first level" -r c:\*.rar *.txt在磁盘C:中的*.RAR 压缩文件中的*.txt 文件中执行区分大小写搜索"first level" 字符串。

2) rarih= f0e0aeaeab2d83e3a9 -r e:\texts在e:\text 目录下的RAR 压缩文件中查找十六进制字符串f0 e0aeaeab 2d 83 e3 a9 。

--------------------------------------------------------------------------------命令K - 锁定压缩文件此命令可防止WinRAR 在未来对压缩文件的任何修改。

此命令行命令相当于压缩文件管理命令锁定压缩文件。

例子:WinRAR k release--------------------------------------------------------------------------------命令M - 移动文件和文件夹到压缩文件类似命令 a ,但在压缩操作成功完成后,文件和文件夹将会被清除。

此命令行等同于添加到压缩文件并且在压缩文件名和参数对话框中启用“压缩之后删除”选项。

因为分卷压缩文件修改是禁用的,所以此命令无法应用在更新分卷压缩,只能创建。

--------------------------------------------------------------------------------命令R - 修复受损的压缩文件压缩文件修复由二个阶段所组成。

首先,损坏的压缩文件会扫描恢复记录(参阅rr命令)。

如果压缩文件包含先前添加的恢复记录,而且损坏的数据部分是连续性的,并低于N*512 字节,N 代表置入压缩文件内恢复扇区的数目,压缩文件成功重建的机会是非常高的。

当此阶段完成时,新的压缩文件将会创建,叫做_recover.rar。

相关文档
最新文档