forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   BlitzMax (http://forum.boolean.name/forumdisplay.php?f=104)
-   -   Releasemutex Api ( hi! ) (http://forum.boolean.name/showthread.php?t=6167)

gatsu. 26.07.2008 02:49

Releasemutex Api ( hi! )
 
Hi!, this is my first post an a Russian forum :)

i'm from italy .. and.. i would use bmax for winapi access...

i used in a my app, the createmutex

Function CreateMutex:Int(lpMutexAttributes :Int , bInitialOwner:Int, lpName : Byte Ptr) = "CreateMutexA@12"


.. but i can't perform the RELEASE....

there is anyone that can post an example for a functionally RELASEMUTEX?
( openmutex can work on Bmax? )

Thx to all :)

alcoSHoLiK 26.07.2008 11:38

Ответ: Releasemutex Api ( hi! )
 
http://msdn.microsoft.com/en-us/library/ms685066.aspx
Цитата:

BOOL WINAPI ReleaseMutex(
__in HANDLE hMutex
);

Parameters

hMutex [in]

A handle to the mutex object. The CreateMutex or OpenMutex function returns this handle.
After calling CreateMutex you get a handle of the newly created mutex. Store it in a variable and pass as an argument to the ReleaseMutex function when you no longer need it.

Check MSDN for additional details.

gatsu. 26.07.2008 16:44

Ответ: Releasemutex Api ( hi! )
 
yes, i do that...

Const ERROR_ALREADY_EXISTS = 183

Extern "win32"
Function CreateMutex:Int(lpMutexAttributes :Int , bInitialOwner:Int, lpName : Byte Ptr) = "CreateMutexA@12"
Function GetLastError:Int() = "GetLastError@0"
Function openmutex:Int(aaaa:Int, bbbb:Int,cccc : Byte Ptr) = "OpenMutex@12"
Function ReleaseMutexA:Int(ffff :Int) = "ReleaseMutex@4"

End Extern

ret = CreateMutex(0,1 ,"MYMUTEX".ToCstring())
If ret<>0 If getlasterror () = ERROR_ALREADY_EXISTS Print "Already present! 1"
Print releasemutexa (ret)

ret = CreateMutex(0,1 ,"MYMUTEX".ToCstring())
If ret<>0 If getlasterror () = ERROR_ALREADY_EXISTS Print "already present! 2"
Print releasemutexa (ret)

'an ... OPENMUTEX test.....

ret = openmutex(0,1 ,"MY MUTEX".ToCstring())

'compiler error:
'untitled4.bmx.gui.release.win32.x86.o: undefined reference to `OpenMutex@12'


but... don't work , what's wrong?

alcoSHoLiK 26.07.2008 20:59

Ответ: Releasemutex Api ( hi! )
 
I'm not able to check this, but I believe it should be either "OpenMutexA@12", or "OpenMutexW@12".

HolyDel 26.07.2008 21:28

Ответ: Releasemutex Api ( hi! )
 
у автора:
Цитата:

cccc : Byte Ptr
значит:
"OpenMutexA@12"

jimon 26.07.2008 22:46

Ответ: Releasemutex Api ( hi! )
 
maybe simple use LoadLibraryA and GetProcAddress functions ?
Код:

lib:Int = LoadLibraryA("somedll.dll")
Global SomeFunction%()"Win32" = GetProcAddress(lib, "SomeFunction@0")


gatsu. 27.07.2008 00:57

Ответ: Releasemutex Api ( hi! )
 
WOW! openmutex seems to work!

Код:

Extern "win32"
        Function CreateMutex:Int(lpMutexAttributes :Int , bInitialOwner:Int, lpName : Byte Ptr) = "CreateMutexA@12"
        Function openmutex:Int(aaaa:Int, bbbb:Int,cccc : Byte Ptr) = "OpenMutexA@12"
End Extern

print "there is mutex: <TEST> ?"
if  openmutex(1,1,"test".tocstring()) print "YES!"; else print "NO!"

print "creating TEST mutex"
CreateMutex(0,1, "test".ToCstring())

if  openmutex(1,1,"test".tocstring()) print "YES!"; else print "NO!"

thx alcoSHoLiK and HolyDel !

for Jimon... umh... i don't know how to use the loadlibraryA... :( ( any example? )

jimon 27.07.2008 01:13

Ответ: Releasemutex Api ( hi! )
 
i see your code works, then you don't need these functions :)

alcoSHoLiK 27.07.2008 03:24

Ответ: Releasemutex Api ( hi! )
 
gatsu.
I'm trying not to be bothersome, but MSDN has answers to all questions regarding Win API ;)
http://msdn.microsoft.com/en-us/libr...75(VS.85).aspx

gatsu. 27.07.2008 05:55

Ответ: Releasemutex Api ( hi! )
 
thx Alcosholik


Часовой пояс GMT +4, время: 22:23.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Перевод: zCarot