Private Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (ByVal lpMutexAttributes As Long, ByVal bInitialOwner As Long, ByVal lpName As String) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const ERROR_ALREADY_EXISTS = 183&
Public Const AppVer = "MyApp v1.1"
Dim mutexvalue As Long
mutexvalue = CreateMutex(ByVal 0&, 1, AppVer)
If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then
CloseHandle mutexvalue
end
End If
Este code no es mio.
en la constante AppVer Pone el caption de la ventana que uses.
le agrege el "end"
(no lo testie, por lo que vi, parece funcionar)
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const ERROR_ALREADY_EXISTS = 183&
Public Const AppVer = "MyApp v1.1"
Dim mutexvalue As Long
mutexvalue = CreateMutex(ByVal 0&, 1, AppVer)
If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then
CloseHandle mutexvalue
end
End If
Este code no es mio.
en la constante AppVer Pone el caption de la ventana que uses.
le agrege el "end"
(no lo testie, por lo que vi, parece funcionar)