甚至有一种更简单的方法:
使用以下代码……
Imports System.IO
在主窗体加载事件上执行以下操作:
If File.Exist(Application.StartupPath & "\abc.txt") Then 'You can change the extension of the file to what ever you desire ex: dll,xyz etc. MsgBox("Only one Instance of the application is allowed!!!") Environment.Exit(0) Else File.Create(Application.StartupPath & "\abc.txt",10,Fileoptions.DeleteonClose) Endif