麻烦老师帮忙看看 为什么打开图片类型的后再次打开图片类型 不会出错
如果打开过office系列的word 或者excel 或者PPT任何一个之后,再次点击打开其他图片或这个文件类型都会提示当前文件正在使用 有没有办法精准关闭当前已经打开过的进程 而不是关闭所有类型进程 比如word进程
代码如下:
Dim wb As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
Dim pc As WinForm.PictureBox = e.Form.Controls("PictureBox1")
wb.Address=""
pc.Image=getimage("")
'判断目录是否存在,如果存在就先删除,再创建,如果不存在就直接创建,确保后续程序可以保存文件并进行阅读或使用
If FileSys.DirectoryExists(ProjectPath & "\Reports") Then '
FileSys.DeleteDirectory(ProjectPath & "\Reports",2,2)
FileSys.CreateDirectory(ProjectPath & "\Reports")
Else
FileSys.CreateDirectory(ProjectPath & "\Reports")
End If
Dim pc2 As WinForm.PictureBox = Forms("主窗口").Controls("PictureBox1")
Dim kp As WinForm.TabControl = Forms("主窗口").Controls("TabControl1")
Dim web1 As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
If FileSys.DirectoryExists(ProjectPath & "\Reports") Then '
Else
FileSys.CreateDirectory(ProjectPath & "\Reports")
End If
If Tables("主窗口_table1").Current Is Nothing Then
Return
Else
Dim dr As DataRow = Tables("主窗口_table1").Current.DataRow
Dim fl As String = ProjectPath & "Reports\" & dr("文件名")
wjdz=fl
Dim str As String = dr("文件名")
Dim Parts() As String = str.Split(".")
vars("文件名")= Parts(0)
'MessageBox.Show(vars("文件名"))
If FileSys.FileExists(fl) AndAlso CRCCheckFile(fl) = dr.SQLGetValue("CRC值") Then '如果本地存在同名文件且CRC校验值相同
'则直接使用本地文件
If fl.EndsWith(".jpg") OrElse fl.EndsWith(".png") OrElse fl.EndsWith(".bmp") OrElse fl.EndsWith(".gif") OrElse fl.EndsWith(".ico") Then
pc2.Image= GetImage(fl)
kp.SelectedIndex=1
Else If fl.EndsWith(".mp4") OrElse fl.EndsWith(".wmv") OrElse fl.EndsWith(".mpg") OrElse fl.EndsWith(".avi") OrElse fl.EndsWith(".m2ts") OrElse fl.EndsWith(".mp3") Then
kp.SelectedIndex=3
e.Form.Controls("Panel2").Basecontrol.controls("mplayer").url = fl
Else If fl.EndsWith(".zip") OrElse fl.EndsWith(".rar") OrElse fl.EndsWith(".exe") OrElse fl.EndsWith(".ppt") OrElse fl.EndsWith(".pptx")Then 'fl.EndsWith(".txt") OrElse fl.EndsWith(".pdf") OrElse
Dim Proc As New Process '打开文件
Proc.File = fl
Proc.Start()
Else
web1.OfficeToolBar = False
web1.Address = fl
kp.SelectedIndex=4
End If
Else '否则从数据库提取文件
If dr.SQLLoadFile("附件",fl) = False Then '如果提取文件失败
Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
Else
If fl.EndsWith(".jpg") OrElse fl.EndsWith(".png") OrElse fl.EndsWith(".bmp") OrElse fl.EndsWith(".gif") OrElse fl.EndsWith(".ico") Then
pc2.Image= GetImage(fl)
kp.SelectedIndex=1
Else If fl.EndsWith(".mp4") OrElse fl.EndsWith(".wmv") OrElse fl.EndsWith(".mpg") OrElse fl.EndsWith(".avi") OrElse fl.EndsWith(".m2ts") OrElse fl.EndsWith(".mp3") Then
kp.SelectedIndex=3
e.Form.Controls("Panel2").Basecontrol.controls("mplayer").url = fl
Else If fl.EndsWith(".zip") OrElse fl.EndsWith(".rar") OrElse fl.EndsWith(".exe") OrElse fl.EndsWith(".ppt") OrElse fl.EndsWith(".pptx") Then 'fl.EndsWith(".txt") OrElse fl.EndsWith(".pdf") OrElse
Dim Proc As New Process '打开文件
Proc.File = fl
Proc.Start()
Else
web1.OfficeToolBar = False
web1.Address = fl
kp.SelectedIndex=4
End If
End If
End If
End If
Dim zt As WinForm.Button = Forms("主窗口").Controls("停止播放")
zt.PerformClick
[此贴子已经被作者于2021/7/5 10:43:53编辑过]