
16/06/2005, 16:33
|
| | Fecha de Ingreso: abril-2005 Ubicación: Huehuetoca, Mexico
Mensajes: 138
Antigüedad: 20 años, 1 mes Puntos: 0 | |
hola de nuevo...Miren encontre este codigo que crea un mutex (creo)..ese es el problema....no lo entiendo.....(soy novato)......me lo podrian explicar un poquito, para saber lo que hace ya que si solo lo uso sin saber su logica jamas voy a progresar...
Private Declare Function CreateMutex Lib "kernel32" Alias _
"CreateMutexA" (lpMutexAttributes As SECURITY_ATTRIBUTES, _
ByVal bInitialOwner As Long, ByVal lpName As String) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Const ERROR_ALREADY_EXISTS = 183&
Public Function InIDE() As Boolean
Debug.Assert Not TestIDE(InIDE)
End Function
Private Function TestIDE(Test As Boolean) As Boolean
Test = True
End Function
Public Function MutexCreate(sName As String) As Boolean
Dim sa As SECURITY_ATTRIBUTES
If Not InIDE Then
sa.bInheritHandle = 1
sa.lpSecurityDescriptor = 0
sa.nLength = Len(sa)
Call CreateMutex(sa, 1, sName)
MutexCreate = (Err.LastDllError <> ERROR_ALREADY_EXISTS)
Else
MutexCreate = True
End If
End Function
Private Sub Form_Load()
If MutexCreate(App.Title) Then
'Continue execution...
Else
MsgBox "Already active!"
End If
End Sub
Bueno gracias por su atencion |