'这样可以防止VB编写的EXE程序改名,居然还有防止exe文件重入的功能。 '但是,第一次运行exe会出错,说是权限问题,以后运行就对了,没找到什么原因。 Option ExplicitDim FileNumber As IntegerPrivate Sub Command1_Click() Unload Me End SubPrivate Sub Form_Load() FileNumber = FreeFile Open App.EXEName & ".exe" For Binary Access Read Lock Read As #FileNumber '锁定EXE文件 End SubPrivate Sub Form_Unload(Cancel As Integer) Close #FileNumber End Sub
和vb无关,vc编写的也是这样。
'但是,第一次运行exe会出错,说是权限问题,以后运行就对了,没找到什么原因。
Option ExplicitDim FileNumber As IntegerPrivate Sub Command1_Click()
Unload Me
End SubPrivate Sub Form_Load()
FileNumber = FreeFile
Open App.EXEName & ".exe" For Binary Access Read Lock Read As #FileNumber '锁定EXE文件
End SubPrivate Sub Form_Unload(Cancel As Integer)
Close #FileNumber
End Sub