PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: EnumWindows  (Read 544 times)

paulDiagnos

  • Guest
EnumWindows
« on: March 06, 2008, 06:47:34 AM »

Hi guys, Im using the following code ...

Code: [Select]
EnumWindows CODEPTR(EnumWindowsProc1), 0

Code: [Select]
FUNCTION EnumWindowsProc1(BYVAL lHandle AS LONG, BYVAL lNotUsed AS LONG) PRIVATE AS LONG
        DIM gsTitle AS GLOBAL STRING
        gsTitle = STRING$(256,0)
        GetWindowText lHandle, BYVAL STRPTR(gsTitle), 256
        gsTitle = EXTRACT$(gsTitle,CHR$(0))
        Dim lResult As long
        IF LEN(gsTitle) THEN
        lResult = MSGBOX("Kill" + gstitle, %MB_OKCANCEL OR %MB_DEFBUTTON2 OR %MB_TASKMODAL, "Critical Warning")
        If lResult  %IDOK Then
        MsgBox "kill"
        sendmessage lHandle,%WM_close,0,0
       
        End If
End If     
       
        FUNCTION = %True
End FUNCTION


And im using this code to try and close a program . unfortantly the program is hidden and can be seen in the task bar.
using the above code i cant even find the window.

any ideas.

thanks Paul.
Logged

paulDiagnos

  • Guest
Re: EnumWindows
« Reply #1 on: March 06, 2008, 09:52:21 AM »

OK figured it out...


you need to find the path of the exe. not the file name, as hidden ones for somereason dont have a name.

Code: [Select]
FUNCTION ParentCallback (BYVAL hWndChild AS LONG, lRaram AS LONG) AS LONG
DIM szClass AS ASCIIZ * %MAX_PATH
DIM szText  AS ASCIIZ * %MAX_PATH
DIM lRes                AS LONG
lRes = GetClassName(hWndChild, szClass, SIZEOF(szClass))
lRes = GetWindowText(hWndChild, szText, SIZEOF(szText))
If szclass = "TPageControl" Then
Sendmessage hwndchild, %WM_ACTIVATE,%WA_CLICKACTIVE , %WA_CLICKACTIVE
TabCtrl_SetCurFocus(hwndchild, 1)
lRes = EnumChildWindows(hWndChild, CODEPTR(ChildCallback), 0&)
End If
Function = 1
END FUNCTION


FUNCTION EnumWindowsProc (BYVAL hwnd AS LONG, BYVAL lParam AS DWORD) AS LONG
   LOCAL Path AS ASCIIZ * %MAX_PATH, TmpAsciiz AS ASCIIZ * 100
   GetPathNameFromWindowHandle hWnd, Path
  If Path <> "" THEN
      GetWindowText hWnd, TmpAsciiz , SIZEOF(TmpAsciiz)
     
        If lcase$(path) = "c:\bluenext\bcu.exe" Then
        sendmessage hWnd,%WM_close,0,0
        End if
   END IF
   FUNCTION = 1
END FUNCTION
Logged