IF FILE(pdffile) DO DECLexewait && declares dlls lcresult = Acrofind() && locates acrobat reader IF EMPTY(lcresult) && could not locate it *--Look for AcroRd32.exe first in the registry lcresult = readregistrykey() IF OCCURS('"',lcresult)>0 IF TYPE('lcresult')="C" .AND. !EMPTY(lcresult) m.cAppName=SUBSTR(lcresult,2,AT('"',lcresult,2)-2) ELSE m.cAppName = '' ENDIF ELSE m.cAppName = lcresult+"AcroRd32.Exe" ENDIF ELSE m.cAppName = lcresult ENDIF IF FILE(m.cAppName) && AcroRd32.exe lcline = " /p /h " IF li_acordview && preview in acrobat reader so user can select printer by ctrl-p lcline = "" ENDIF SET DEFAULT TO LEFT(hdir,RAT("\",hdir)-1) lnpos=(RAT("\",m.cAppName)+1) && one position to the right of lcshort='' lcpath='' IF lnpos > 0 lcshort = UPPER(SUBSTR(m.cAppName,lnpos)) && grab from lnpos to end lcpath = UPPER(LEFT(m.cAppName,RAT("\",m.cAppName)-1)) && strip off the extension ENDIF IF !EMPTY(lcshort) .AND. !EMPTY(lcpath) lcpath = "'"+lcpath+"'" SET DEFAULT TO &lcpath llacordok = ExeWait(lcshort,lcline+hdir+xacordform+'.xfdf',lcpath) ELSE llacordok = ExeWait( m.cAppName, lcline+xacordform+'.xfdf',hdir) ENDIF IF !llacordok =MESSAGEBOX("Unable to print Acord Form.",0+16+4096,"ERROR") ELSE WAIT WINDOW "Finished Printing" NOWAIT ENDIF SET DEFAULT TO &lcACORDdef ELSE =MESSAGEBOX('Unable to locate Acrobat Reader. Please install and try again',0+16+4096,'ERROR - Acrobat Reader Missing.') ENDIF DO RELexewait ELSE =MESSAGEBOX("Unable to create Acord Form.",0+16+4096,"ERROR - PDF or XFDF Missing.") ENDIF PROCEDURE DECLexewait && load required dlls for exewait function =ADLLS(dllarray) IF ASCAN(dllarray,'CREATEPROCESS') = 0 DECLARE INTEGER CreateProcess IN kernel32; INTEGER lpAppName, STRING lpCmdLine, INTEGER lpProcAttr,; INTEGER lpThrAttr, INTEGER bInhHandles, INTEGER dwCrFlags,; INTEGER lpEnvir, INTEGER lpCurDir, ; STRING @lpStInfo, STRING @lpProcInfo ENDIF IF ASCAN(dllarray,'GETLASTERROR') = 0 DECLARE INTEGER GetLastError IN kernel32 ENDIF IF ASCAN(dllarray,"CLOSEHANDLE") = 0 DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject ENDIF IF ASCAN(dllarray,"GETEXITCODEPROCESS") = 0 DECLARE INTEGER GetExitCodeProcess IN WIN32API INTEGER hProcess, INTEGER @lpExitCode ENDIF IF ASCAN(dllarray,"SLEEP") = 0 DECLARE Sleep IN kernel32 INTEGER dwMilliseconds ENDIF RETURN PROCEDURE RELexewait && release dlls for exewait function CLEAR DLLS CreateProcess CLEAR DLLS GetLastError CLEAR DLLS CloseHandle CLEAR DLLS GetExitCodeProcess CLEAR DLLS Sleep RETURN *--Uses GetExitcodeProcess instead of waitforsingleobject PROCEDURE ExeWait (lcApp, lcCmdLine, lcdir) PRIVATE lntimes lntimes = 0 IF _VFP.AUTOYIELD = .F. llsetback = .T. ELSE llsetback = .F. ENDIF _VFP.AUTOYIELD = .T. PRIVATE lnclosepass lnclosepass = 0 #DEFINE INFINITE 0xFFFFFFFF LOCAL lcStartupInfo, lcProcInfo, hProcess, ; lnPrio, lnIBelieve1 lnIBelieve1 = 1 && Don't remember what that was lnPrio = 32 && Priority of Process=Normal lcStartupInfo = CHR(68) + REPLI(CHR(0), 67) lcProcInfo = REPLI(CHR(0), 16) IF CreateProcess(0, m.lcApp+" "+m.lcCmdLine+CHR(0), 0,0,; m.lnIBelieve1, m.lnPrio,; 0, 0, @lcStartupInfo, @lcProcInfo) <> 0 * process and thread handles returned in ProcInfo structure hProcess = buf2dword(SUBSTR(lcProcInfo, 1,4)) hThread = buf2dword(SUBSTR(lcProcInfo, 5,4)) * waiting until the termination of the program DOEVENTS IF !li_acordview && printing only DO stopadobe ELSE DO WHILE .T. exitcode = 0 && initialize return value to 0 = GetExitCodeProcess(hProcess, @exitcode) && try to obtain process exit code IF exitcode # 259 && not still busy EXIT && fall out of loop ELSE *--Attempt to close the password window up to 3 times IF dopass .and. lnclosepass < 3 .AND. PassWin('Password') = Sleep (1000) && wait 1 seconds lnclosepass = lnclosepass + 1 ENDIF ENDIF = Sleep (100) && wait .1 seconds ENDDO ENDIF = CloseHandle(hThread) = CloseHandle(hProcess) ELSE IF llsetback _VFP.AUTOYIELD = .F. ENDIF RETURN .F. ENDIF IF llsetback _VFP.AUTOYIELD = .F. ENDIF RETURN