just what the subject says. I don't want the user to be able to run my prog more than one instance at a time, not from the original location nor from a different one ( a copy of it). Thanks in advance.
Posted on 2001-01-31 05:10:00 by your mama
Try something I like this. I think I got it off this board and it works good. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;creates mutex to determine if this only instance of program. ;if already running ExitProcess is called invoke CreateMutex,NULL,1,ADDR MutexObj mov hMutex,eax invoke GetLastError .if eax==ERROR_ALREADY_EXISTS invoke CloseHandle,hMutex jmp @f .endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; best regards, czDrillard
Posted on 2001-01-31 10:11:00 by czDrillard
I am writing a little program and use this code to see if it is already running : findcls: push 0 push offset szClassName call FindWindow ;Is this window ;already registered? or eax,eax jz regclass ;no it's not ! push MB_OK push offset szDisplayName push offset already push 0 call MessageBox ;call message box to tell user ;that a copy is already running. xor eax,eax jp end_loop ;exit from prog... regclass: ; here, we continue... invoke GetCommandLine mov CommandLine, eax invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT invoke InitCommonControls etc... obs : this is not my code, I don't remember where I got it. regards ssaguiar
Posted on 2001-01-31 21:20:00 by ssaguiar
Just to add in another one, you can create an event: .data EventName BYTE "SingleInstEvent",0 .code invoke CreateEvent ,NULL,FALSE,TRUE,ADDR EventName .IF eax!=NULL invoke GetLastError .IF eax==ERRROR_ALREADY_EXISTS ;You app is already running .ENDIF .ENDIF
Posted on 2001-02-01 03:12:00 by X
yeah but it stops use of the same program on the same PC only.. i think "your mama" was also thinking to stop ANY second use of the program...
Posted on 2001-02-01 18:01:00 by BogdanOntanu