CODESEG

PROC START

XOR EDI,EDI
CALL GetCommandLineA
MOV ,EAX
CALL GetModuleHandleA,EDI
MOV ,EAX
;Test for previous instance
CALL CreateSemaphore,0,0,1,OFFSET Semafor
MOV ESI,EAX
CALL GetLastError
CMP EAX,ERROR_SUCCESS
JE @@FirstInst
CMP EAX,ERROR_ALREADY_EXISTS
JNE @@Exist
CALL CloseHandle,ESI
@@Exist:
CALL FindWindow,OFFSET TFrameName,0
OR EAX,EAX
JE @@FirstInst
MOV ESI,EAX
CALL IsIconic,EAX
OR EAX,EAX
JE @@Activate
CALL ShowWindow,ESI,SW_RESTORE
JMP @@SendCmdLine
@@Activate:
CALL SetForegroundWindow,ESI
@@SendCmdLine:
MOV EDI,
MOV AL,' '
MOV ECX,300
REPNE SCASB
CMP ,0
JE QUIT
MOV ECX,300
@@Find1:
CMP ,' '
JA @@Find2
INC EDI
LOOP @@Find1
JMP QUIT
@@Find2:
MOV EBX,EDI
MOV ,EDI
@@Find3:
INC EDI
CMP ,' '
JB @@Find4
JE @@Find5
LOOP @@Find3
JMP QUIT
@@Find5:
MOV ,0
@@Find4:
INC EDI
SUB EDI,EBX
MOV ,EDI
CALL SendMessage,ESI,WM_COPYDATA,0,OFFSET AppSend
JMP QUIT
@@FirstInst:
; Here is your usual program code - the real program.....

QUIT:
CALL ExitProcess,0

ENDP


This is what I use, and it works.....
Posted on 2001-08-16 05:26:11 by ivogelov