flat assembler
Message board for the users of flat assembler.
Index
> Windows > Unique instance with a Mutex not working. |
Author |
|
revolution 23 Aug 2011, 12:18
Have you read this?:
Win32 Doc wrote: lpName |
|||
23 Aug 2011, 12:18 |
|
rohagymeg 23 Aug 2011, 12:24
revolution wrote: Have you read this?: Amazing! I couldn't figure that out myself! It's there because in c++ it worked for me that way. Somewhere there was a random mutex name generator and I just pasted it there and it completely worked in code::blocks |
|||
23 Aug 2011, 12:24 |
|
AsmGuru62 23 Aug 2011, 13:06
Pretty cool!
MSDN says that "Global\" is a valid prefix: http://msdn.microsoft.com/en-us/library/ms682411(v=VS.85).aspx In FASM a double backslash will produce a double backslash! In C++, however, this turned into a single one, which is valid! That shows that paths and names can't be "ported" into FASM just by copying stuff. btw: URL tag is not working. Edit by revolution: Fixed url tag |
|||
23 Aug 2011, 13:06 |
|
revolution 23 Aug 2011, 13:14
AsmGuru62 wrote: MSDN says that "Global\" is a valid prefix |
|||
23 Aug 2011, 13:14 |
|
vid 23 Aug 2011, 13:20
You also could have checked the error code from GetLastError.
|
|||
23 Aug 2011, 13:20 |
|
rohagymeg 23 Aug 2011, 13:36
vid wrote: You also could have checked the error code from GetLastError. I sent this pm to revolution but I'll put it here, too: If I comment out the getlasterror line CreateMutexA doesn't work. Otherwise it works. Is getlasterror a requirement for this function to return a value? Code: format PE GUI 4.0 include "win32ax.inc" invoke CreateMutexA, 0, 1, mutex_name invoke GetLastError ;this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! cmp eax, 0 je another_instance_not_found invoke MessageBoxA, 0, "Another instance found!", "Test", MB_OK invoke ExitProcess, 1 another_instance_not_found: invoke MessageBoxA, 0, "Another instance NOT found!", "Test", MB_OK invoke ExitProcess, 0 data import library kernel32,'KERNEL32.DLL',user32,'USER32.DLL' import kernel32,\ ExitProcess,'ExitProcess', CreateMutexA,'CreateMutexA',\ GetLastError,'GetLastError' import user32,\ MessageBoxA,'MessageBoxA' end data mutex_name db "d41d8cd98f00b204e9800998ecf8427e",0 |
|||
23 Aug 2011, 13:36 |
|
rohagymeg 23 Aug 2011, 13:56
Everything is fine, I just understood that it returns with GetLastError, and CreateMutexA returns the mutex handle so it always showed the same return value because I checked eax after CreateMutexA, not after GetLastError, which returns ERROR_ALREADY_EXISTS, and that's what I was looking for to ensure that only one instance is running.
|
|||
23 Aug 2011, 13:56 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.