以记事本为例
目前创新互联建站已为1000+的企业提供了网站建设、域名、虚拟主机、绵阳服务器托管、企业网站设计、桥东网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
Public Class Form1
Public Sub ShellAndWait(ByVal ProcessPath As String)
Dim objProcess As System.Diagnostics.Process
Try
objProcess = New System.Diagnostics.Process()
objProcess.StartInfo.FileName = ProcessPath
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
objProcess.Start()
objProcess.WaitForExit()
objProcess.Close()
Catch
MessageBox.Show("无法执行文件 " ProcessPath, "错误")
End Try
End Sub
'监视程序就可以了,若果监视别的窗体的话,用SPY++ 找到句柄,配合FindWindowEx,SendMessage根据其属性做
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ShellAndWait("Notepad.exe")
MessageBox.Show("笔记本被关闭后我才会出现")
End Sub
End Class
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
FileSystemWatcher1.NotifyFilter = IO.NotifyFilters.DirectoryName Or IO.NotifyFilters.FileName‘监控文件夹和文件。
FileSystemWatcher1.IncludeSubdirectories = True’监控子文件夹
End Sub
Private Sub FileSystemWatcher1_Renamed(sender As Object, e As IO.RenamedEventArgs) Handles FileSystemWatcher1.Renamed
MsgBox(e.FullPath vbCrLf e.Name)
End Sub'捕获新路径
你监控test不就好了,若要排除其他文件夹,IncludeSubdirectories 设为假,用多个FileSystemWatcher就行了,用数组或其他方式创建。
给你个工程自己看...
运行后可以看到自己...
点按钮保存到c:\1.bmp
这个还需要代码么?
VB不会.C#大约像这样:
从工具箱上拖一个该控件.
设置属性如下:
最后注册该控件的Change事件即可