CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Mutexes

  1. #1
    Join Date
    Jul 2001
    Location
    Mumbai,India
    Posts
    382

    Mutexes

    Does anyone know how to use the CreateMutex,
    ResumeMutex and WaitForSingleObject APIs?

    An example would be very helpful.

    Thanks in advance.
    Regards,
    The Beret.



    Regards,
    The Beret.

  2. #2
    Join Date
    Mar 2001
    Posts
    10

    Re: Mutexes

    here is some code for create mutex:


    'declarations
    Global ThisAppMutex as Long
    Global hInstanceMutex as Long

    public Declare Function OpenMutex& Lib "kernel32" Alias "OpenMutexA" (byval dwDesiredAccess as Long, byval bInheritHandle as Long, byval lpName as string)
    public Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (byval lpMutexAttributes as Long, byval bInitialOwner as Long, byval lpName as string) as Long
    public Declare Function CloseHandle Lib "kernel32" (byval hObject as Long) as Long
    public Declare Function GetLastError Lib "kernel32" () as Long


    'create mutex
    Dim hInstanceMutexHandle as Long
    Dim MutexHandle as Long
    hInstanceMutexHandle = CreateMutex(0, true, "SomeValueYouSet")
    If (Err.LastDllError = ERROR_ALREADY_EXISTS) then
    If (hInstanceMutexHandle) then
    Call CloseHandle(hInstanceMutexHandle)
    End
    End If
    End If
    ThisAppMutex = hInstanceMutexHandle





    Hope this helps.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured