Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WInApi32 Closehandle ...not working

Status
Not open for further replies.

waynebrady

Programmer
Feb 20, 2003
24
US
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
 
Another way to do this is to send a close message to the window via API call...take a look at the solution proposed by Chris in the following thread:

Controlling Adobe Acrobat
thread184-722247

boyd.gif

craig1442@mchsi.com
&quot;Whom computers would destroy, they must first drive mad.&quot; - Anon​
 
Craig,

Thanks for your help. That solution works perfectly. I still don't understand why the "closehandle" option doesn't work. Oh well, I appreciate the response.

Thanks again,



Wayne Brady
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top