Make your own free website on

[an error occurred while processing this directive]
'This code must be pasted into a module
'Set the project's startup object to 'Sub Main' (-> Project -> Project Properties -> General Tab -> Startup Object)
Public Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (lpMutexAttributes As SECURITY_ATTRIBUTES, ByVal bInitialOwner As Long, ByVal lpName As String) As Long
        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Long
End Type
Public Const ERROR_ALREADY_EXISTS = 183&
Private Sub Main()
    'KPD-Team 1999
    ' -> code by Raist Lin
    sa.bInheritHandle = 1
    sa.lpSecurityDescriptor = 0
    sa.nLength = Len(sa)
    'Try to create a new Mutex
    Debug.Print CreateMutex(sa, 1, App.Title)
    Debug.Print Err.LastDllError
    'Check if the function was succesfull
    If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then
        'More than one instance detected
        MsgBox "More than one instance"
        'No other instance detected...
        'Your program-load code here
    End If
End Sub

Copyright © 1998-2000, The KPD-Team.
Send mail to with comments about this web site.
This site is located at