long time agoes before we move the board to this server i've seen someone post how to define share section in MASM that
we can use it to check how many instance of our program running.

i try to search in for the board but can not find that thread.
anyone know how to define that kind of share section?
Posted on 2001-10-09 11:57:32 by doby
Add "/section:.data,rws" to the linker parameters

Dont forget to check as soon as possible, before writing anything else to global variables.

japheth
Posted on 2001-10-10 02:09:17 by japheth
Perhaps that solution is possible, but I'd probably go for other
methods,
like memory mapped files. Or perhaps I should just investigate this
"shared section" stuff :).
Posted on 2001-10-10 04:00:25 by f0dder
long time agoes before we move the board to this server i've seen someone post how to define share section in MASM that
we can use it to check how many instance of our program running.


Maybe you're talking about a Mutex ?

Latigo
Posted on 2001-10-10 10:45:48 by latigo
Mutexs don't tell a process how many other instances are running, it'll just stop two running in "parallel".

It depends on what you want to do.
If you just want to stop multiple instances running latigo's right a mutex is the best way to do it.

Mirno
Posted on 2001-10-10 10:55:01 by Mirno
i got it, thanks japheth, your answer is what i want.
f0dder, latigo, Mirno Thanks for your answer too. :)

i post my code below may be someone interested in.



share SEGMENT
running db 0
share ENDS

.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax

mov ah, running
cmp ah,1
jz @F

mov running, byte ptr 1
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess, eax

szTitle db 'Error!',0
szMsg db 'This program is already running',0
@@:
invoke MessageBox,0,ADDR szMsg,ADDR szTitle,MB_OK
invoke ExitProcess, 0


link with "/section:share,rws"
Posted on 2001-10-11 16:16:56 by doby