Switched to VB method of single instance

This commit is contained in:
MikeMaximus
2017-12-09 10:09:01 -06:00
parent 7330c5bcba
commit 8907933285
5 changed files with 24 additions and 52 deletions
-16
View File
@@ -1825,23 +1825,9 @@ Public Class frmMain
oProcess.StartTime = Now : oProcess.EndTime = Now oProcess.StartTime = Now : oProcess.EndTime = Now
End Sub End Sub
Private Function IsGBMRunning() As Boolean
Dim prsList() As Process = Process.GetProcessesByName("GBM")
If prsList.Length > 1 Then
Return True
Else
Return False
End If
End Function
Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Init 'Init
Try Try
'Ensure only one instance is running
If IsGBMRunning() Then
mgrCommon.ShowMessage(frmMain_ErrorAlreadyRunning, MsgBoxStyle.Exclamation)
ShutdownApp(False)
Else
SetForm() SetForm()
VerifyGameDataPath() VerifyGameDataPath()
LoadAndVerify() LoadAndVerify()
@@ -1870,8 +1856,6 @@ Public Class frmMain
Me.gMonTray.Visible = True Me.gMonTray.Visible = True
End If End If
End If End If
End If
Catch ex As Exception Catch ex As Exception
If mgrCommon.ShowMessage(frmMain_ErrorInitFailure, ex.Message, MsgBoxStyle.YesNo) = MsgBoxResult.No Then If mgrCommon.ShowMessage(frmMain_ErrorInitFailure, ex.Message, MsgBoxStyle.YesNo) = MsgBoxResult.No Then
bInitFail = True bInitFail = True
+1 -1
View File
@@ -24,7 +24,7 @@ Namespace My
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New() Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false Me.IsSingleInstance = true
Me.EnableVisualStyles = true Me.EnableVisualStyles = true
Me.SaveMySettingsOnExit = false Me.SaveMySettingsOnExit = false
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
+1 -1
View File
@@ -2,7 +2,7 @@
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain> <MySubMain>true</MySubMain>
<MainForm>frmMain</MainForm> <MainForm>frmMain</MainForm>
<SingleInstance>false</SingleInstance> <SingleInstance>true</SingleInstance>
<ShutdownMode>0</ShutdownMode> <ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles> <EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode> <AuthenticationMode>0</AuthenticationMode>
-9
View File
@@ -2832,15 +2832,6 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to An instance of Game Backup Monitor is already running..
'''</summary>
Friend ReadOnly Property frmMain_ErrorAlreadyRunning() As String
Get
Return ResourceManager.GetString("frmMain_ErrorAlreadyRunning", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to GBM is running from a new location, the Windows startup entry has been updated.. ''' Looks up a localized string similar to GBM is running from a new location, the Windows startup entry has been updated..
'''</summary> '''</summary>
-3
View File
@@ -1945,7 +1945,4 @@
<data name="frmSettings_chkSessionTracking" xml:space="preserve"> <data name="frmSettings_chkSessionTracking" xml:space="preserve">
<value>Enable session tracking</value> <value>Enable session tracking</value>
</data> </data>
<data name="frmMain_ErrorAlreadyRunning" xml:space="preserve">
<value>An instance of Game Backup Monitor is already running.</value>
</data>
</root> </root>