M m.posseth Nov 11, 2005 #2 use a mutex see: http://groups.google.nl/group/micro...l+posseth+mutex&rnum=1&hl=nl#079b5ad8b16ab96e regards Michel Posseth [MCP]
use a mutex see: http://groups.google.nl/group/micro...l+posseth+mutex&rnum=1&hl=nl#079b5ad8b16ab96e regards Michel Posseth [MCP]
R Robert Liles Nov 11, 2005 #3 This only works if you are loading a Windows Form, not a Module. Bobbo If NoLoad(Me) then end Private Declare Auto Function FindWindow Lib "user32.dll" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr Private Declare Auto Function ShowWindow Lib "user32.dll" _ (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean Public Function NoLoad(ByRef sender As System.Object) As Boolean If UBound(System.Diagnostics.Process.GetProcessesByName( _ System.Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then Const SW_RESTORE As Integer = 9 Dim SearchText As String = sender.Text sender.Text = sender.Text & "X" ShowWindow(FindWindow(Nothing, SearchText), SW_RESTORE) sender.Text = SearchText Return True Else Return False End If End Function ___________________________________________________________
This only works if you are loading a Windows Form, not a Module. Bobbo If NoLoad(Me) then end Private Declare Auto Function FindWindow Lib "user32.dll" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr Private Declare Auto Function ShowWindow Lib "user32.dll" _ (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean Public Function NoLoad(ByRef sender As System.Object) As Boolean If UBound(System.Diagnostics.Process.GetProcessesByName( _ System.Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then Const SW_RESTORE As Integer = 9 Dim SearchText As String = sender.Text sender.Text = sender.Text & "X" ShowWindow(FindWindow(Nothing, SearchText), SW_RESTORE) sender.Text = SearchText Return True Else Return False End If End Function ___________________________________________________________
H Herfried K. Wagner [MVP] Nov 11, 2005 #4 ucasesoftware said: how to have only one instance of my application ? Click to expand... <URL:http://dotnet.mvps.org/dotnet/code/application/#SingleInstance>
ucasesoftware said: how to have only one instance of my application ? Click to expand... <URL:http://dotnet.mvps.org/dotnet/code/application/#SingleInstance>