|
-
October 11th, 2001, 09:26 PM
#1
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.
-
October 16th, 2001, 04:10 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|