Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
HProcess -- waiting for Word to complete
Message
From
09/02/2002 09:51:56
 
 
To
08/02/2002 11:21:51
Patrick O'Neil
American Specialty Information Services
Roanoke, Indiana, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00617439
Message ID:
00617888
Views:
25
>can anyone tell me how i can get the process handle for Word when i create an instance of Word ?
>i.e. i create an instance of word using this:
>
>
>   obj_Word = CREATEOBJECT( "Word.Application" )
>   obj_Word.VISIBLE = .T.
>     ...
>
>
>and the user does some typing and editing in Word.
>(i've created a toolbar with two macro buttons, which amount to
>-- "save stuff to clipboard and quit Word" and
>-- "empty the clipboard and quit Word".
>
>back in my VFP app, i want to be able to sit there and wait for them to quit Word, at which time i will store the clipboard contents into a memo field.
>
>from a previous article here, i found i could start a process and wait for it to complete by doing the following (i'm using Adobe distiller in this example) :
>
>
>Startup_Info = long2str(68) + REPLICATE(CHR(0), 64)
>Process_Info = REPLICATE(CHR(0), 16)
>Command_String = ALLTRIM(Distiller_EXE_Spec) + ' ' + ;
>                 ALLTRIM(PS_PDF_Combiner_File_Spec) + CHR(0)
>Return_Code = CreateProcess(0 , Command_String , 0 , 0 , 1 , NORMAL_PRIORITY_CLASS, 0, 0, @Startup_Info, @Process_Info )
>IF Return_Code = 0
>  =MESSAGEBOX("Error occurred. Error code: ", GetLastError())
>  RETURN
>ENDIF
>hProcess = str2long(SUBSTR(Process_Info, 1, 4))
>DO WHILE ( .T. )
>  IF ( WaitForSingleObject(hProcess, WAIT_INTERVAL) != WAIT_TIMEOUT )
>    EXIT
>  ELSE
>    DOEVENTS
>  ENDIF
>ENDDO
>Return_Code = CloseHandle (hProcess)
>
>
>
>i want to learn how to get the process hande when i start Word using the CREATEOBJECT technique as shown above.
>
>any help would sure be appreciated.

You can't use hProcess monitoring for Word, as all instances of Word share a common hProcess and the value returned is a virtual hProcess IAC. Your best bet would be to minitor the FileChange event for the target file for a file close event, to recognize that Word has released the target file. Word's Quit event isn't a really good alternative if there might be more than one instance of Word active at one time.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform