waynebrady
Programmer
Using VFP 7.0. I'm trying to close and external application using VFP. Specifically Adobe Acrobat. Acrobat is running when I execute the following.
Code is as follows:
DECLARE INTEGER BringWindowToTop IN Win32API ;
INTEGER hWnd
DECLARE INTEGER GetActiveWindow ;
IN Win32API
DECLARE INTEGER GetWindow IN Win32API ;
INTEGER hWnd, INTEGER nType
DECLARE INTEGER GetWindowText IN Win32API ;
INTEGER hWnd, STRING @cText, INTEGER nType
DECLARE INTEGER GetLastError IN win32api
DECLARE INTEGER CloseHandle IN win32api INTEGER
tcTitle='Adobe Acrobat'
lcClosit=.t.
hNext = GetActiveWindow() && current app's window
* iterate through the open windows
DO WHILE hNext<>0
cText = REPLICATE(CHR(0),80)
GetWindowText(hNext,@cText,80)
&& get window title
IF UPPER(ALLTRIM(tcTitle)) $ UPPER(cText)
* parameter text is present in window title
* Adobe is running, so try to close it
IF lcClosit
=CloseHandle(hNext)
?getlasterror()
ELSE
=BringWindowToTop(hNext)
ENDIF
EXIT
ENDIF
hNext = GetWindow(hNext,2) && next window
ENDDO
If Adobe is running then it is brought to the "front".
I can't get the adobe application to close. I get a getlasterror()=87 (I don't have a error matrix).
Can anyone identify my problem?
Thanks,
Wayne Brady
Code is as follows:
DECLARE INTEGER BringWindowToTop IN Win32API ;
INTEGER hWnd
DECLARE INTEGER GetActiveWindow ;
IN Win32API
DECLARE INTEGER GetWindow IN Win32API ;
INTEGER hWnd, INTEGER nType
DECLARE INTEGER GetWindowText IN Win32API ;
INTEGER hWnd, STRING @cText, INTEGER nType
DECLARE INTEGER GetLastError IN win32api
DECLARE INTEGER CloseHandle IN win32api INTEGER
tcTitle='Adobe Acrobat'
lcClosit=.t.
hNext = GetActiveWindow() && current app's window
* iterate through the open windows
DO WHILE hNext<>0
cText = REPLICATE(CHR(0),80)
GetWindowText(hNext,@cText,80)
&& get window title
IF UPPER(ALLTRIM(tcTitle)) $ UPPER(cText)
* parameter text is present in window title
* Adobe is running, so try to close it
IF lcClosit
=CloseHandle(hNext)
?getlasterror()
ELSE
=BringWindowToTop(hNext)
ENDIF
EXIT
ENDIF
hNext = GetWindow(hNext,2) && next window
ENDDO
If Adobe is running then it is brought to the "front".
I can't get the adobe application to close. I get a getlasterror()=87 (I don't have a error matrix).
Can anyone identify my problem?
Thanks,
Wayne Brady