Hello! Who can help me?!
How can current application (Process/Task) detect and close?
...definite Task terminate?
Thank
How can current application (Process/Task) detect and close?
...definite Task terminate?
Thank
I need a similar thing. 1 My DOS program shells to my Windows program. 2 My Windows program needs to know when another Windows program has terminated. I know the name of the program that I'm waiting for to terminate by pressing Ctrl+Alt+Del.
#Include "Win32Api.Inc" $HookFile = "C:\HookWnd.Id" Global hDlg As Long, hHook As Long, hInstDLL As Long Global TmpAsciiz As Asciiz * 256, ReadyToTerminate As Long Function LibMain(ByVal hInstance As Long, ByVal fwdReason As Long, _ ByVal lpvReserved As Long) Export As Long Select Case fwdReason Case %DLL_PROCESS_ATTACH: GetModuleFileName(GetModuleHandle(ByVal %Null), TmpAsciiz, _ SizeOf(TmpAsciiz) If LCase$(Right$(TmpAsciiz, 12)) = "\notepad.exe" Or _ LCase$(Right$(TmpAsciiz, 12)) = "\winword.exe" Or _ LCase$(Right$(TmpAsciiz, 12)) = "\wordpad.exe" Then _ ReadyToTerminate = %True hInstDLL = hInstance: LibMain = 1 Case %DLL_PROCESS_DETACH: LibMain = 1 End Select End Function Function HookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) Export As Long Function = CallNextHookEx(ByVal hHook, ByVal nCode, ByVal wParam, ByVal lParam) If hDlg = 0 Then Open "C:\HookWnd.Id" For Input Shared As #1: _ Input #1, hDlg, hHook: Close #1 If IsWindow(hDlg) = %False Then FreeLibrary hInstDll ' Normal termination of DLL, when Spy exe is finished Else If ReadyToTerminate And wParam = &H91 Then _ FreeLibraryAndExitThread hInstDll, 0 Else _ PostMessage hDlg, %WM_USER + 1, wParam, lParam End If End Function Function SetHookKbdWindow Alias "SetHookKbdWindow" (hWnd As Long) Export As Long hHook = SetWindowsHookEx (%WH_KEYBOARD, _ CodePtr(HookProc), ByVal hInstDLL, ByVal 0) Open $HookFile For Output As #1: Print #1, hWnd, hHook;: Close End Function Function UnHookKbdWindow Alias "UnHookKbdWindow" Export As Long UnhookWindowsHookEx hHook: Kill $HookFile End Function
#Compile Exe #Dim All #Register None #Include "Win32Api.Inc" Declare Function SetHookKbdWindow Lib "Hook.Dll" _ Alias "SetHookKbdWindow" (hWnd As Long) As Long Declare Function UnHookKbdWindow Lib "Hook.Dll" _ Alias "UnHookKbdWindow" As Long CallBack Function DlgProc Static Id As Long Select Case CbMsg Case %WM_INITDIALOG SetHookKbdWindow CbHndl Case %WM_DESTROY UnHookKbdWindow Case %WM_USER + 1 Incr Id SetWindowText CbHndl, "KbdHook Id = " + Str$(id) Control Set Text CbHndl, 101, _ "WParam =" + Hex$(CbWparam) + _ " LParam =" + Hex$(CbLparam) + _ " at " + Time$ Function = 1: Exit Function End Select End Function Function PbMain() Local hDlg As Long Dialog New 0, "", 0, 0, 200, 40, %WS_SYSMENU, %WS_EX_TOPMOST To hDlg Control Add Label, hDlg, 101, "", 5, 5, 200, 12 Dialog Show Modal hDlg Call DlgProc End Function
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment