Hi All !
How to check from code is the prog is running like in Word .?
I want to associate my prog with it own file extantion and when user double click on file run my prog and open file but then user click on second file I do not want to run second prog copy ,
but open file in running prog.
Regards,
Igor .
Posted on 2002-06-10 08:22:34 by Zebio
Please use the search engine of this board and search for the keywords "single instance"
Posted on 2002-06-10 08:28:21 by bazik
I talk about my old prog that I want modify
who have some interest please downlad it here
http://www.hot.ee/kuldbyte/clipline.zip

any lang support
drag and drop support
autosave every 6 min in to file "autosave.cln"
load autosave at start
have own extantion *.cln
You can associate clipline.exe files with *.cln file format for faster open it
Enjoy LOL :)
All comments welcomed

Igor
Posted on 2002-06-10 08:35:58 by Zebio
2 bAZiK
Thanks I trying use search befor and after post my Q
and couldn foun answer to my Q :( maybe I read careless
I try agayn
Thanks
Posted on 2002-06-10 08:52:14 by Zebio
i made it in the past this way after some debugging .




AmITheFirst proc

lea edx,offset MutexName
invoke CreateMutex, NULL,FALSE,edx
invoke WaitForSingleObject ,eax,0

ret
;===== Data ========
MutexName:
db 'Pure', 0
;===== Data End ====

AmITheFirst endp


this proc return 0 if this is the first run
else ( != 0 ) it is not the first run.

tested on win98 & win2k

for more detail read about mutex.
Posted on 2002-06-10 08:59:48 by Sa6ry
heres how i do it.
add this to your Link when you compile.
/section:share,rws
in your .asm


share segment
AppInit dd 0
share ends

startupcodex proc
cmp AppInit,1; if its 1 then a program has already loaded
je @F; jmp is its equ
mov AppInit,1;else its 0 and we mov 1 into it
jmp endFFFF;return to code
@@:
invoke ExitProcess,0;end
endFFFF:
ret
startupcodex endp
Posted on 2002-06-10 12:14:28 by Qages
You look good for me thanks
the another prob appear How to transmit command line to
allready running prog ?
thanks ,
Zebio
Posted on 2002-06-10 13:01:13 by Zebio
if you mean you want your prog to execute a nother proc, well make a nother dd in the share seg, have that 2nd app check it for a number 1, if it matches, then call,... but i dont know exactly what u want...
Posted on 2002-06-10 13:07:09 by Qages

2 bAZiK
Thanks I trying use search befor and after post my Q
and couldn foun answer to my Q :( maybe I read careless
I try agayn
Thanks


Is it that hard to enter the two keywords I told you?

Fourth result:
Single Instance of an application
Posted on 2002-06-10 13:07:25 by bazik
c'mon give the man a break, hes only 15posts!
Posted on 2002-06-10 13:17:27 by Qages
<USENET>
Unless he's 5 years old, he's able to use the search option...
The post count is not a valid excuse...

*plonk*
</USENET>

Seriously, this forum is up for a year now, and with the contributions of many capable and helpful programmers, the forum archive itself is now a huge programming database where you we can find answers to many questions...
The point is here : having a fast answer is the bottom line ?
What is the fastest way to have it? The search option...
Posted on 2002-06-10 14:22:16 by JCP
This below is search result that I get using you keywords "single instance" maybe I push wrong button Sorry then but below i nothing that I looking for



Win32ASM Community messageboard > Search > Thread Results
Displaying Topics 1 to 12 of 12

Thread Thread Starter Forum Replies Views Last Post
How to avoid execute 2 copy of same prog ? Zebio Main 9 105 June 10th, 2002 07:17 PM
by Qages

3. A Simple Window Hiroshimator Iczelion's tutorials 2 385 April 20th, 2002 12:23 PM
by Thomas

Delete Executable Tsongkie Main 5 271 April 10th, 2002 02:44 PM
by hutch--

To DLL or not to DLL, that is my question! Maelstrom Main 48 1162 February 21st, 2002 12:35 AM
by hutch--

Nested procedures ? Ray Main 28 470 February 19th, 2002 02:12 AM
by tank

Multiedit with more than 32k memory Nordwind64 Main 3 138 February 13th, 2002 06:47 PM
by Nordwind64

wanna help me parse this string? smurf Main 4 122 February 3rd, 2002 10:37 PM
by f0dder

a few questions Mikky Main 5 146 January 21st, 2002 12:02 AM
by f0dder

MessageBox ownership... matthew Main 1 56 November 29th, 2001 09:43 AM
by hutch--

32. Multiple Document Interface (MDI) Hiroshimator Iczelion's tutorials 0 232 July 8th, 2001 01:07 AM
by Hiroshimator

27. Tooltip Control Hiroshimator Iczelion's tutorials 0 233 July 8th, 2001 01:01 AM
by Hiroshimator
Posted on 2002-06-10 14:29:03 by Zebio
Then archive this forum and close it put link to to file for download
instead keep forum opened for posts
Posted on 2002-06-10 14:35:22 by Zebio
No, because more questions and answers to these questions can be added... (of course, I'm talking about new questions, not ones that has already been discussed on 3 or 4 threads).

Another one : http://www.asmcommunity.net/board/index.php?topic=160&highlight=singleinstance
Posted on 2002-06-10 16:51:36 by JCP
check out www.madwizard.org - snippets library, where you'll find a lot of algo's... :)
Posted on 2002-06-10 17:00:43 by stryker
Thanks every one for help, my problem is solved
Zabio. :alright:
Posted on 2002-06-10 17:25:24 by Zebio
You can also fire up prostart and click the single instance code checkbox.
Posted on 2002-06-10 22:04:50 by grv575
Thanks
I look now for the best way to send message with command line
from second started prog to already runing . Please give me some advice .
PS.
Also I'm very ineresting hear any comments how my prog work on the different OS win2k n XP couse I have 98 Please try it
http://www.hot.ee/kuldbyte/clipline.zip only 18 kb zip

Zebio .
Posted on 2002-06-11 03:42:06 by Zebio

You can also fire up prostart and click the single instance code checkbox.


prostart can DO that????

Dang! I'm gonna start using some of the other utilities with MASM32... I mean, they take up KILOBYTES of my precious HDD space....
Posted on 2002-06-11 04:14:08 by AmkG

Thanks
I look now for the best way to send message with command line
from second started prog to already runing . Please give me some advice .


Why? For single instance code?



; #################################################

.486
.model flat, stdcall
option casemap :none

; #################################################

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

; #################################################

StartProgram PROTO

; #################################################

.data
szMutexAppName db "MY_APP_MUTEX", 0
szAlreadyRunning db "Another Instance of this Application is already running!", 0
szRunsNow db "This App runs now!", 13,10, "Leave this MessageBox open ",
"and doubleclick the exe again!", 0


; #################################################

.data?
hMutex dd ?


; #################################################

.code

start:

invoke CreateMutex, 0, 1, addr szMutexAppName
mov hMutex, eax
invoke GetLastError

.if eax == ERROR_ALREADY_EXISTS
invoke MessageBox, 0, addr szAlreadyRunning, 0, 0
jmp @F
.endif

call StartProgram
@@:
invoke CloseHandle, hMutex
invoke ExitProcess, 0

StartProgram proc

invoke MessageBox, 0, addr szRunsNow, 0, 0
ret

StartProgram endp

end start

; #################################################
Posted on 2002-06-11 04:29:45 by bazik