设置 Shell = 新 (Shell.appliecaton)
set Shell = new (Shell.appliecaton)
我一直在使用 Shell 解压缩文件。突然它停止工作并出现错误:
"Class does not support Automation or does not support expected interface"
如果我在 Win7 机器上构建它,它可以在 Win7 机器上运行,但不能在 Win10 上运行。
如果我在 Win10 机器上构建它,它会在 Win10 机器上运行,但不会在 Win7 机器上运行。
在 Win7 机器上构建时,早期版本 运行 在两台机器上都很好。
我仔细比较了 .aip 构建文件(高级安装程序),它们是相同的。我已经有 3 或 4 个月没有碰过有问题的代码了。
这是我正在使用的代码(您可能认识它):
{
昏暗 Shell 分类为 shell32.Shell
将文件源调暗为 shell32.Folder
Dim Filedest 为 shell32.Folder
将文件夹项目变暗为 shell32.Folder 项目
If sFileSource = "" Or sFileDest = "" Then
GoTo Zip_Activity_Err
End If
Select Case UCase$(Action)
Case "ZIPFILE"
If Right$(UCase$(sFileDest), 4) <> ".ZIP" Then
sFileDest = sFileDest & ".ZIP"
End If
If Not Create_Empty_Zip(sFileDest) Then
GoTo Zip_Activity_Err
End If
Set ShellClass = New shell32.Shell
Set Filedest = ShellClass.NameSpace(sFileDest)
Call Filedest.CopyHere(sFileSource, 20)
Case "ZIPFOLDER"
If Right$(UCase$(sFileDest), 4) <> ".ZIP" Then
sFileDest = sFileDest & ".ZIP"
End If
If Not Create_Empty_Zip(sFileDest) Then
GoTo Zip_Activity_Err
End If
Set ShellClass = New shell32.Shell
Set FileSource = ShellClass.NameSpace(sFileSource)
Set Filedest = ShellClass.NameSpace(sFileDest)
Set Folderitems = FileSource.Items
Call Filedest.CopyHere(Folderitems, 20)
Case "UNZIP"
If Right$(UCase$(sFileSource), 4) <> ".ZIP" Then
sFileSource = sFileSource & ".ZIP"
End If
Set ShellClass = New shell32.Shell <--- Here's where it fails
Set FileSource = ShellClass.NameSpace(sFileSource)
Set Filedest = ShellClass.NameSpace(sFileDest)
Set Folderitems = FileSource.Items
Filedest.CopyHere Folderitems, _
NoUserInterfaceIfErr + _
NoConfirmOfNewDir + _
YesToAll + NoProgBox
Case Else
End Sele
}
解决方案可能是使用后期绑定。
所以使用Set Obj = CreateObject("Shell.Application")
后期绑定是一种对话。
YourProg:嗨 shell,你有 namespace
命令吗?
Shell:是的,我知道,这是命令编号 5。
YourProg:请执行命令 5 - 这是参数
Shell:这是 return 数据,如果有的话。
提前绑定你的程序是用 GUID 编译的,并跳转到 vtable 中的第 5 个偏移量。
我一直在使用 Shell 解压缩文件。突然它停止工作并出现错误:
"Class does not support Automation or does not support expected interface"
如果我在 Win7 机器上构建它,它可以在 Win7 机器上运行,但不能在 Win10 上运行。 如果我在 Win10 机器上构建它,它会在 Win10 机器上运行,但不会在 Win7 机器上运行。 在 Win7 机器上构建时,早期版本 运行 在两台机器上都很好。
我仔细比较了 .aip 构建文件(高级安装程序),它们是相同的。我已经有 3 或 4 个月没有碰过有问题的代码了。
这是我正在使用的代码(您可能认识它):
{ 昏暗 Shell 分类为 shell32.Shell 将文件源调暗为 shell32.Folder Dim Filedest 为 shell32.Folder 将文件夹项目变暗为 shell32.Folder 项目
If sFileSource = "" Or sFileDest = "" Then
GoTo Zip_Activity_Err
End If
Select Case UCase$(Action)
Case "ZIPFILE"
If Right$(UCase$(sFileDest), 4) <> ".ZIP" Then
sFileDest = sFileDest & ".ZIP"
End If
If Not Create_Empty_Zip(sFileDest) Then
GoTo Zip_Activity_Err
End If
Set ShellClass = New shell32.Shell
Set Filedest = ShellClass.NameSpace(sFileDest)
Call Filedest.CopyHere(sFileSource, 20)
Case "ZIPFOLDER"
If Right$(UCase$(sFileDest), 4) <> ".ZIP" Then
sFileDest = sFileDest & ".ZIP"
End If
If Not Create_Empty_Zip(sFileDest) Then
GoTo Zip_Activity_Err
End If
Set ShellClass = New shell32.Shell
Set FileSource = ShellClass.NameSpace(sFileSource)
Set Filedest = ShellClass.NameSpace(sFileDest)
Set Folderitems = FileSource.Items
Call Filedest.CopyHere(Folderitems, 20)
Case "UNZIP"
If Right$(UCase$(sFileSource), 4) <> ".ZIP" Then
sFileSource = sFileSource & ".ZIP"
End If
Set ShellClass = New shell32.Shell <--- Here's where it fails
Set FileSource = ShellClass.NameSpace(sFileSource)
Set Filedest = ShellClass.NameSpace(sFileDest)
Set Folderitems = FileSource.Items
Filedest.CopyHere Folderitems, _
NoUserInterfaceIfErr + _
NoConfirmOfNewDir + _
YesToAll + NoProgBox
Case Else
End Sele
}
解决方案可能是使用后期绑定。
所以使用Set Obj = CreateObject("Shell.Application")
后期绑定是一种对话。
YourProg:嗨 shell,你有 namespace
命令吗?
Shell:是的,我知道,这是命令编号 5。
YourProg:请执行命令 5 - 这是参数
Shell:这是 return 数据,如果有的话。
提前绑定你的程序是用 GUID 编译的,并跳转到 vtable 中的第 5 个偏移量。