Private Sub Command1_Click() Open "aa.txt" For Append As #1 Print #1, "sadgfsdfsd" End SubPrivate Sub Command2_Click() Close End SubPrivate Sub Command3_Click() Name "aa.txt" As "bb.txt" End Sub
Private Sub Command1_Click() Shell "平抛运动的演示.exe", 1 End SubPrivate Sub Command2_Click() On Error GoTo 100 Open "平抛运动的演示.exe" For Append As #1 ' Print #1, "" Close 1 Exit Sub 100 MsgBox "程序已经运行!" End Sub Private Sub Command3_Click() On Error GoTo 100 Name "平抛运动的演示.exe" As "temp.temp" Name "temp.temp" As "平抛运动的演示.exe" Exit Sub 100 MsgBox "程序已经运行!" End Sub
Lock Read Write只能限制其他进程,对程序自身却无能为力。
如果你关心很多文件,或者所有文件,那么你用API WaitForSingleObject或者WaitForMultipleObjects来实时监视某一组文件(在一个或多个目录下)状态是否改变了
Open "aa.txt" For Append As #1
Print #1, "sadgfsdfsd"
End SubPrivate Sub Command2_Click()
Close
End SubPrivate Sub Command3_Click()
Name "aa.txt" As "bb.txt"
End Sub
Shell "平抛运动的演示.exe", 1
End SubPrivate Sub Command2_Click()
On Error GoTo 100
Open "平抛运动的演示.exe" For Append As #1
' Print #1, ""
Close 1
Exit Sub
100
MsgBox "程序已经运行!"
End Sub Private Sub Command3_Click()
On Error GoTo 100
Name "平抛运动的演示.exe" As "temp.temp"
Name "temp.temp" As "平抛运动的演示.exe"
Exit Sub
100
MsgBox "程序已经运行!"
End Sub