VB中奖UnRAR.exe将RAR解压到指定文件夹

VB中奖UnRAR.exe将RAR解压到指定文件夹,第1张

rarFile = "1RAR"

newFolder="D:\"

Shell AppPath & IIf(Right(AppPath, 1) = "\", "", "\") & "unrar x " & rarFile & " " & newFolder

给你个VB遍历文件的代码吧

Private

Declare

Function

FindFirstFile

Lib

"kernel32"

Alias

"FindFirstFileA"

(ByVal

lpFileName

As

String,

lpFindFileData

As

WIN32_FIND_DATA)

As

Long

'查找下一个文件的API

Private

Declare

Function

FindNextFile

Lib

"kernel32"

Alias

"FindNextFileA"

(ByVal

hFindFile

As

Long,

lpFindFileData

As

WIN32_FIND_DATA)

As

Long

'获取文件属性的API

Private

Declare

Function

GetFileAttributes

Lib

"kernel32"

Alias

"GetFileAttributesA"

(ByVal

lpFileName

As

String)

As

Long

'关闭查找文件的API

Private

Declare

Function

FindClose

Lib

"kernel32"

(ByVal

hFindFile

As

Long)

As

Long

Const

MAX_PATH

=

260

Const

MAXDWORD

=

&HFFFF

Const

FILE_ATTRIBUTE_DIRECTORY

=

&H10

Private

Type

FILETIME

dwLowDateTime

As

Long

dwHighDateTime

As

Long

End

Type

Dim

tempstr

As

String

'定义类(用于查找文件)

Private

Type

WIN32_FIND_DATA

dwFileAttributes

As

Long

ftCreationTime

As

FILETIME

ftLastACCESSTime

As

FILETIME

ftLastWriteTime

As

FILETIME

nFileSizeHigh

As

Long

nFileSizeLow

As

Long

dwReserved0

As

Long

dwReserved1

As

Long

cFileName

As

String

MAX_PATH

cAlternate

As

String

14

End

Type

Dim

filecount

As

Integer

Dim

dirs()

As

String

Dim

curr

As

Long

Dim

ss()

As

String

Private

Sub

Command1_Click()

tempstr

=

"c:"

searchdir

tempstr

filecount

=

0

End

Sub

Public

Function

searchdir(path

As

String)

Dim

WFD

As

WIN32_FIND_DATA

Dim

i

As

Long

Dim

temp

As

String

Dim

h

As

Long

Dim

zhaodao

As

Long

Dim

iindex

As

Integer

Dim

dirs()

As

String

Dim

l

As

Long

zhaodao

=

1

h

=

FindFirstFile(path

&

"\",

WFD)

If

h

<>

-1

Then

While

zhaodao

zhaodao

=

1

temp

=

Left(WFDcFileName,

InStr(WFDcFileName,

Chr$(0))

-

1)

If

temp

<>

""

And

temp

<>

""

Then

If

WFDdwFileAttributes

And

vbDirectory

Then

ReDim

Preserve

dirs(iindex)

dirs(iindex)

=

path

&

"\"

&

temp

iindex

=

iindex

+

1

ReDim

Preserve

ss(filecount)

ss(filecount)

=

path

&

"\"

&

temp

filecount

=

filecount

+

1

End

If

End

If

zhaodao

=

FindNextFile(h,

WFD)

Wend

End

If

FindClose

(h)

If

iindex

>

0

Then

For

i

=

0

To

iindex

-

1

Call

searchdir(dirs(i))

Next

i

End

If

End

Function

不是找不到text1text的文件,而是找不到rarexe。

你要把C:\Program Files\WinRAR下的Rarexe复制到已经生成应用程序的目录下。如果要在调试模式下运行,就要复制到VB的安装目录下(就是VB6EXE所在的目录)。

以上就是关于VB中奖UnRAR.exe将RAR解压到指定文件夹全部的内容,包括:VB中奖UnRAR.exe将RAR解压到指定文件夹、VB获取文件夹路径、vb中winrar应用,程序解压缩等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9636857.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存