News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Gui demo to start another app with termination notification

Started by hutch--, August 26, 2005, 12:27:23 PM

Previous topic - Next topic

hutch--

This demo shows how to run an external app asynchronously without any "shell" style procedures, wait states and the like and receive notification when the external app terminates. The price is you must be running an external app you wrote yourself as it sends a registered message using the HWND_BROADCAST handle to the system that is trapped by the calling process as termination notification.

The advantage is in a normal GUI application is that you can keep working with the calling app while the other is running asynchronously and receive notification when it has finished.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm

Hello,
There is no price proceding as the sample i have joined
It used  invoke FindWindow,addr ClassName,NULL
You have write it , so you know it's classname,and you got i's handle and there is no need to broadcast the message.
The sample create an atom ,that is join with the message, so the two aplications can exchange data.
                    ToutEnMasm







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

.386                      ; force 32 bit code
.model flat, stdcall      ; memory model & calling convention
option casemap :none      ; case sensitive

; -------------------------------------------------------------------
; Les fichiers inclus içi ,AUCUN .lib c'est au programme utilisateur
; de les fournir
; -------------------------------------------------------------------
include \masm32\include\windows.inc
; include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
; include \masm32\include\masm32.inc
include macros.txt

; ---------------------------------------------------------
; Les PROTO sont tous regroupés dans un fichier .inc du même
; nom que la librairie .lib
;EnvoyerMessageEditmasm PROTO  :DWORD ,:DWORD

; ---------------------------------------------------------

;
;exemples de definitions externes
; EXTERNDEF Copier :PROTO  :DWORD,:DWORD
; EXTERNDEF EtatMemoirePile :MEMORY_BASIC_INFORMATION
; EXTERNDEF PoriginePile:DWORD

.data
;--------------------data---------------------
NomServeur db "EditMasm Version 2",0
MarqueurImprime db "imprime:",0;"except:",0
AtomRubrique db (MAX_PATH +1) dup (0)
MesEditmasm db "WM_EDITMASM",0
ValueMesEditmasm dd 0
ClassName       db  'EditMasm',0
HandleEditmasm  dd 0
.code

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

EnvoyerMessageEditmasm PROC  adrChaine:DWORD , Handle:DWORD
Local aApp:DWORD
Local aTopic:DWORD
Local  Biatom:DWORD
Local  retour:DWORD
Local phrase[MAX_PATH]:BYTE
ZEROLOCALES phrase
;Local   :DWORD
mov retour,1
.if adrChaine == 0
mov retour,0
jmp FindeEnvoyerMessageEditmasm
.endif
invoke lstrlen,adrChaine
.if eax == 0 || eax > 255 -9 ;8 +1
mov retour,0
jmp FindeEnvoyerMessageEditmasm
.endif

.if ValueMesEditmasm == 0
;demander le numéro du message au système
invoke RegisterWindowMessage,addr MesEditmasm   ;db "WM_EDITMASM",0
mov ValueMesEditmasm,eax
.endif
;échec de RegisterWindowMessage
.if ValueMesEditmasm == 0
mov retour,0
jmp FindeEnvoyerMessageEditmasm
.endif
;search handle of editmasm
.if HandleEditmasm == 0
invoke FindWindow,addr ClassName,NULL
mov HandleEditmasm,eax
.endif
.if HandleEditmasm == 0
mov retour,0
jmp FindeEnvoyerMessageEditmasm
.endif

;-------- former les atoms ------------------
invoke GlobalAddAtom,addr NomServeur
.if eax == 0
mov retour,0
jmp FindeEnvoyerMessageEditmasm
.endif
mov aApp,eax
and eax,0FFFFh
shl eax,16
mov Biatom,eax ;mot supérieur "EditMasm Version 2"
;-------------------------------------------------------------
;--------------- create the data -----------------
invoke lstrcat,addr phrase,addr MarqueurImprime
invoke lstrcat,addr phrase,adrChaine
invoke GlobalAddAtom,addr phrase
.if eax == 0
invoke GlobalDeleteAtom,aApp
mov retour,0
jmp FindeEnvoyerMessageEditmasm
.endif
mov aTopic,eax
and eax,0FFFFh
add Biatom,eax
;------------ the HWND_BROADCAST is not necessary --------
;-----------------------------------------------------------------------
invoke SendMessage,HandleEditmasm,ValueMesEditmasm,Handle,Biatom
;-----------------------------------------------------------------------
invoke GlobalDeleteAtom,aApp
invoke GlobalDeleteAtom,aTopic

FindeEnvoyerMessageEditmasm:
mov eax,retour
ret
EnvoyerMessageEditmasm endp


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