Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ShellExecute WaitForSingleObject IsRunning(GeorgeTasker)
Message
From
19/03/2004 12:00:48
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
ShellExecute WaitForSingleObject IsRunning(GeorgeTasker)
Miscellaneous
Thread ID:
00887963
Message ID:
00887963
Views:
201
I am having problems using ShellExecute, IsRunning, and WaitforsingleObject together. I am trying to start Adobe Acrobat Reader using the associated .pdf's .xfdf file. Adobe Acrobat Reader opens up fine and uses the .xfdf file as it should. However, I need to stop processing in my app until Adobe Acrobat Reader is closed so I can then delete the .pdf and .xfdf files. I cannot use createprocess because createprocess only works with executables. The handle returned by isrunning is never found using waitforsingleobject. Any idea how can I convert the value returned by isrunning() to a value required by waitforsingleobject?

Here is my code:
oShellCmd = NEWOBJECT('_shellexecute', '_environ.vcx')
oShellCmd.ShellExecute(xacordform+'.xfdf',LEFT(hdir,RAT("\",hdir)-1), 'Open')
INKEY(5.2)
#DEFINE INFINITE  0xFFFFFFFF
DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
DECLARE INTEGER WaitForSingleObject IN kernel32;
   INTEGER hHandle, INTEGER dwMilliseconds
lnhandle=ISRUNNING('Adobe')

*--This never waits because the value returned from isrunning() is not
*--what waitforsingleobject requires
=WaitForSingleObject ( lnHandle, INFINITE ) 
=CloseHandle( lnHandle ) 

*--George Tasker's IsRunning Utility
FUNCTION IsRunning
LPARAMETER pctitle
DECLARE INTEGER GetDesktopWindow IN Win32API
DECLARE INTEGER GetWindow IN Win32API;
  INTEGER hwnd, INTEGER dflag
DECLARE INTEGER GetWindowText IN Win32API ;
  INTEGER hwnd, STRING @lptstr, INTEGER cbmax

LOCAL lnhwnd, lnnext, lldone, lctitle_bar, lcsearchfor,;
  lntext_len
lcsearchfor = UPPER(ALLTRIM(pctitle))
lnhwnd = GetDesktopWindow()
lnhwnd = GetWindow(lnhwnd, 5) && Get first child window
lnnext = 2
lldone = .F.
lctitle_bar = ""
DO WHILE NOT lldone
  IF NOT EMPTY(lnhwnd)
    lctitle_bar = SPACE(200) + CHR(0)
    lntext_len = GetWindowText(lnhwnd, @lctitle_bar, 200)
    lctitle_bar = UPPER(LEFT(lctitle_bar, lntext_len))
    lldone = (lcsearchfor $ lctitle_bar)
    IF NOT lldone
      lnhwnd = GetWindow(lnhwnd, lnnext)
    ENDIF
  ELSE
    lldone = .T.
  ENDIF
ENDDO
RETURN lnhwnd
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Next
Reply
Map
View

Click here to load this message in the networking platform