在vb6.0中用ShellExecute打开了一个1.pdf文件之后,在退出程序的时,怎样才能关闭打开的1.pdf文档呢
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
‘打开文件Private Sub Command1_Click()
Dim Sfile As String
Dim lR As Long
Sfile = App.Path & "\调整.pdf"
lR = ShellExecute(Me.hWnd, "Open", Sfile, "", "", vbNormalFocus)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'关闭打开的文件 App.Path & "\调整.pdf"
这里怎么写End Sub
[解决办法]
改用Shell写的,你可以参考一下
Option Explicit
'打开文件
Private Sub Command1_Click()
Dim Sfile As String
Dim lR As Long
Sfile = "D:\Login.bmp"
lR = Shell("C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe d:\雨林木风 WinXP SP2 安装版 Y3.5.pdf", vbNormalFocus)
Command1.Caption = lR
End Sub
'关闭文件
Private Sub Command2_Click()
Dim lngP As Long
If IsNumeric(Command1.Caption) Then Shell "taskkill.exe /PID " & Command1.Caption
End Sub