Detect multiple run

BlitzPlus Forums/BlitzPlus Programming/Detect multiple run

Another way is to create a mutex each time you start your application. If the mutex is already opened, the application is already running.

I tried this:

.lib "kernel32.dll"

CreateMutex%(lpMutexAttributes*,bInitialOwner,lpName$):"CreateMutexA" 
GetLastError%():"GetLastError"


Const ERROR_ALREADY_EXISTS=183

mutex$="Choose_something"
attributes=CreateBank(4)
PokeInt attributes,0,0

mutex_h=CreateMutex(attributes,1,mutex$)
FreeBank(attributes)

If GetLastError() <> ERROR_ALREADY_EXISTS
 Print "1st time."
Else
 Print "Already running."
EndIf

Input 
End


It's a better way than FindWindow, but sadly it does not work. I always get an ERROR_INVALID_PARAMETER from GetLastError. I guess the problem is that the 2nd parameter must a BOOL (a byte) , is it possible to pass a byte to a DLL under Blitz ?