I would like to plan for different possibilities that may occur when
a program is run.
What would happen to the O.S. if the program was ended by Task Manager?
What other "collateral damage" could occur ?
.ELSEIF uMsg==WM_DESTROY
invoke UnregisterHotKey,hWnd,065h
invoke GlobalFree,hglb; help by Nathan in comp.lang.asm.x86
invoke PostQuitMessage,NULL
.ELSEIF uMsg == WM_HOTKEY
; Put text on the clipboard.
invoke OpenClipboard,NULL
.IF (eax)
invoke EmptyClipboard
invoke GlobalAlloc,GMEM_MOVEABLE, 128; Allocate some space.
.IF (eax)
mov hglb, eax
invoke GlobalLock,hglb
mov ebx, eax
push ebx ; Save ebx
mov eax, lParam
shr eax, 16
.if ax == 65 ; If the key 65 ("A") was pressed.
invoke MemCopy,ADDR str1,ebx,SIZEOF str1
.elseif ax == 66 ; If the key 66 ("B") was pressed.
invoke MemCopy,ADDR str2,ebx,SIZEOF str2
.else
; Some other key pressed.
.endif
invoke SetClipboardData,CF_TEXT,hglb
.IF (eax == 0)
invoke MessageBox,NULL, ADDR AppName,ADDR Mess1, MB_ICONEXCLAMATION
.ENDIF
pop eax ; Restore the value that was saved from ebx
invoke GlobalUnlock, eax
.ELSE
invoke MessageBox,NULL, ADDR AppName,ADDR Mess2, MB_ICONEXCLAMATION
.ENDIF
invoke GlobalFree, hglb
invoke CloseClipboard
Quote
What would happen to the O.S. if the program was ended by Task Manager?
On win XP ,vista,win 7 ,NOTHING
For the program,all data can be lost.
So, are you saying that only my keyboard shortcuts would be lost?
All things installed by your program would be lost (keyboard shortcuts,...),YES