vb.net – “make single instance application”这是做什么的?

前端之家收集整理的这篇文章主要介绍了vb.net – “make single instance application”这是做什么的?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在vb 2008 express中,此选项在应用程序属性下可用.有谁知道它的功能是什么?这样做是为了不可能同时打开两个实例吗?
甚至有一种更简单的方法

使用以下代码……

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

这将处理单个实例以及瘦客户端,并且在应用程序运行时无法删除文件.关闭应用程序或者如果应用程序崩溃,文件将自行删除.

原文链接:https://www.f2er.com/vb/255791.html

猜你在找的VB相关文章