是否有人有一个示例代码来说明如何阻止启动.exe文件?
这样的事可能有用:
For Each OSKInstance As Process In Process.GetProcessesByName("OSK").ToArray
OSKInstance.Kill()
Next
但是,由于while循环一直在运行,因此资源可能非常紧张。是否有更智能的方法来锁定.exe?
答案 0 :(得分:0)
找到代码:
Dim myFileStream As System.IO.FileStream
Dim sFileName As String = Application.StartupPath & "\test.exe"
'block
myFileStream = New System.IO.FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.None)
'unblock
myFileStream.Close()