8. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 8/3/2017 10:10:40 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

8.1 Files compared

# Location File Last Modified
1 V31A.zip\V31A\434\OR_30_434V114_SRC\XE8\508\VA 508 JAWS Framework\Source JAWSImplementation.pas Tue Apr 18 19:44:14 2017 UTC
2 V31A.zip\V31A\434\OR_30_434V114_SRC\XE8\508\VA 508 JAWS Framework\Source JAWSImplementation.pas Thu Aug 3 13:27:33 2017 UTC

8.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 5392
Changed 2 4
Inserted 0 0
Removed 0 0

8.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

8.4 Active regular expressions

No regular expressions were active.

8.5 Comparison detail

  1   { ******** ********** ********** ********** ********** ********** ********** **********
  2     {
  3     {                                    JAWS  FrameWork
  4     {
  5     { The fr amework ke eps the ja ws scripts  updated a nd acts as  a middle  man to the
  6     { Jaws a pplication .
  7     {
  8     {
  9     {
  10     { Last m odified by : Chris Be ll
  11     { Last m odified: 5 /25/16
  12     { Last M odified De scription:
  13     {   Adde d splash s creen with  version i nformation  as well a s an updat e to the n ew log con trol
  14     {
  15     {
  16     { DONE - oJeremy Me rrill -c50 8 :
  17     Add some thing that  prevents  overwritin g of the s cript file s if anoth er
  18     app is r unning tha t's using  the JAWS D LL }
  19   { DONE -oJ eremy Merr ill -c508  : Add chec k in here  to look at  script ve rsion in J SS file -
  20       DN S      BELLC: Thi s appears  to already  be added.  Marking a s done }
  21   { DONE -oJ eremy Merr ill -c508  :
  22     Replace  registry c ommunicati on with mu ltiple win dows - sav e strings  in the win dow titles
  23     Use Enum erateChild Windows ja ws script  function i n place of  the FindW indow func tion
  24     that's b eing used  right now. - Enumerat eChildWind ows with a  window ha ndle of 0
  25     enumerat es all win dows on th e desktop.   Will hav e to use t he first p art of the  window
  26     title as  an ID, an d the last  part as t he string  values.  W ill need t o check fo r a maximu m
  27     string l enght, pro bably have  to use mu ltiple win dows for l ong text.
  28     Will als o beed to  have a glo bal window  shared by  muiltiple  instances  of the JA WS.SR DLL.  }
  29   { DONE -oJ eremy Merr ill -c508  :
  30     Need to  add versio n checking  to TVA508 Accessibil ityManager  component
  31     and JAWS .DLL.  War ning needs  to displa y just lik e JAWS.DLL  and JAWS.  }
  32   { DONE -oJ eremy Merr ill -c508  :Figure ou t why Delp hi IDE is  loading th e DLL when  JAWS is r unning  -
  33     probably  has somet hing to do  with the  VA508 pack age being  installed  -
  34     need to  test for c sDesigning  some plac e that we' re not tes ting for ( maybe?) }
  35   { DONE -oJ eremy Merr ill -c508  :
  36     Change A PP_DATA so  that "app lication d ata" isn't  used - Wi ndows Vist a
  37       doesn't us e this val ue - get d ata from W indows API  call -  DN S      BELLC:
  38     This is  no longer  an issue s ince we do  not call  this funct ion. }
  39  
  40   { DONE -oC hris Bell  -c508 : Ad d log abil ity }
  41   { DONE -oC hris Bell  -c508 : Me rge dispat cher into  DLL to cir cumvent th e UAC warn ing with w indows 7 }
  42   { DONE -oC hris Bell  -c508 : Co rrect issu e with UIP I since Ja ws runs at  a higher  priority a s CPRS. Th is limits  API calls.  }
  43   { DONE -oC hris Bell  -c508 : Mo dify code  to accommo date for u sers lack  of Admin r ights. }
  44   { TODO -oC hris Bell  -c508 : Ma ss code cl eanup. }
  45   { TODO -oC hris Bell  -c508 : Up date jcScr iptMerge c ode }
  46   { ******** ********** ********** ********** ********** ********** ********** **********  }
  47  
  48   unit JAWSI mplementat ion;
  49  
  50   interface
  51  
  52   uses
  53   {$IFDEF VE R180}
  54     Messages ,
  55   {$ELSE}
  56     Winapi.M essages,
  57   {$ENDIF}
  58     SysUtils , Windows,  Classes,  Registry,  StrUtils,  Forms, Dia logs,
  59     ExtCtrls , VAUtils,  DateUtils , PSApi, I niFiles, A ctiveX, SH Folder,
  60     ShellAPI , VA508Acc essibility Const, fVA 508Dispatc herHiddenW indow, U_L ogObject;
  61  
  62   {$I 'VA508 ScreenRead erDLLStand ard.inc'}
  63   Function F indCommand Switch(Swi tchName: s tring; var  ReturnVal ue: string )
  64     : Boolea n; overloa d;
  65   Function F indCommand Switch(Swi tchName: s tring): Bo olean; ove rload;
  66  
  67   exports In itialize,  ShutDown,  RegisterCu stomBehavi or, Compon entData, S peakText,
  68     IsRunnin g, ConfigC hangePendi ng
  69   {$IFDEF VE R180}
  70     ;
  71   {$ELSE}
  72     , FindJa ws;
  73   {$ENDIF}
  74  
  75   implementa tion
  76  
  77   uses fVA50 8HiddenJaw sMainWindo w, FSAPILi b_TLB, Com Obj, tlhel p32, U_Spl ashScreen,
  78     Vcl.Cont rols;
  79  
  80   const
  81  
  82     JAWS_COM _OBJECT_VE RSION = '8 .0.2173';
  83     VA508_RE G_COMPONEN T_CAPTION  = 'Caption ';
  84     VA508_RE G_COMPONEN T_VALUE =  'Value';
  85     VA508_RE G_COMPONEN T_CONTROL_ TYPE = 'Co ntrolType' ;
  86     VA508_RE G_COMPONEN T_STATE =  'State';
  87     VA508_RE G_COMPONEN T_INSTRUCT IONS = 'In structions ';
  88     VA508_RE G_COMPONEN T_ITEM_INS TRUCTIONS  = 'ItemIns tructions' ;
  89     VA508_RE G_COMPONEN T_DATA_STA TUS = 'Dat aStatus';
  90     SLASH =  '\';
  91     JAWS_COM MON_SCRIPT _PATH_TEXT  = 'freedo m scientif ic\jaws\';
  92     JAWS_REG ROOT = 'SO FTWARE\Fre edom Scien tific\JAWS ';
  93     JAWS_SCR IPTDIR = ' SETTINGS\e nu';
  94     JAWS_INS TALL_DIREC TORY_VAR =  'Target';
  95     JAWS_SHA RED_DIR =  'Shared\';
  96     KEY_WOW6 4_64KEY =  $0100;
  97  
  98   type
  99     TCompare Type = (jc Prior, jcI NI, jcLine Items, jcV ersion, jc ScriptMerg e,
  100       jcINIM RG, jcLine ItemsMRG);
  101  
  102     TAddFile s = record
  103       FileNa me: string ;
  104     end;
  105  
  106     TFileInf o = record
  107       FileNa me: string ;
  108       Compar eType: TCo mpareType;
  109       Requir ed: Boolea n;
  110       Compil e: Boolean ;
  111       Exist:  Boolean;
  112       Add_To _Uses: arr ay of TAdd Files;
  113       Depend encies: ar ray of TAd dFiles;
  114     end;
  115  
  116     TFileInf oArray = A rray of TF ileInfo;
  117  
  118   const
  119     JAWS_SCR IPT_NAME =  'VA508JAW S';
  120     JAWS_APP _NAME = 'V A508APP';
  121     JAWS_SCR IPT_VERSIO N = 'VA508 _Script_Ve rsion';
  122     JAWS_FRA MEWORK_USE S = ';VA50 8_FRAMEWOR K_USES';
  123     JAWS_SCR IPT_LIST =  'VA508Scr iptList.IN I';
  124     Compiled ScriptFile Extension  = '.JSB';
  125     ScriptFi leExtensio n = '.JSS' ;
  126     ScriptDo cExtension  = '.JSD';
  127     ConfigFi leExtensio n = '.JCF' ;
  128     KeyMapEx tension =  '.JKM';
  129     Dictiona ryFileExte nsion = '. JDF';
  130     Jaws_Scr ipt_Folder  = 'Jaws S cripts';
  131  
  132     JAWS_VER SION_ERROR  = ERROR_I NTRO +
  133       'The A ccessibili ty Framewo rk can onl y communic ate with J AWS ' +
  134       JAWS_R EQUIRED_VE RSION + CR LF +
  135       'or la ter versio ns.  Pleas e update y our versio n of JAWS  to a minim um of' +
  136       CRLF +  JAWS_REQU IRED_VERSI ON +
  137       ', or  preferably  the most  recent rel ease, to a llow the A ccessibili ty' + CRLF
  138       + 'Fra mework to  communicat e with JAW S.  If you  are getti ng this me ssage' +
  139       CRLF +  'and you  already ha ve a compa tible vers ion of JAW S, please  contact yo ur'
  140       + CRLF  + 'system  administr ator, and  request th at they ru n, with ad ministrato r rights,'
  141       + CRLF  + 'the JA WSUpdate a pplication  located i n the \Pro gram Files \VistA\' +
  142       CRLF +  'Common F iles direc tory. JAWS Update is  not requir ed for JAW S' + CRLF
  143       + 'ver sions ' +  JAWS_COM_O BJECT_VERS ION + ' an d above.'  + CRLF;
  144  
  145     JAWS_FIL E_ERROR =  ERROR_INTR O +
  146       'The J AWS interf ace with t he Accessi bility Fra mework req uires the  ability' +
  147       CRLF +  'to write  files to  the hard d isk, but t he followi ng error i s occurrin g trying t o'
  148       + CRLF  + 'write  to the dis k:' + CRLF  + '%s' +  CRLF +
  149       'Pleas e contact  your syste m administ rator in o rder to en sure that  your ' +
  150       CRLF +  'security  privilege s allow yo u to write  files to  the hard d isk.' +
  151       CRLF +  'If you a re sure yo u have the se privile ges, your  hard disk  may be ful l.  Until'
  152       + CRLF  + 'this p roblem is  resolved,  the Access ibility Fr amework wi ll not be  able to'
  153       + CRLF  + 'commun icate with  JAWS.';
  154  
  155     JAWS_USE R_MISSMATC H_ERROR =  ERROR_INTR O +
  156       'An er ror has be en detecte d in the s tate of JA WS that wi ll not all ow the' +
  157       CRLF +  'Accessib ility Fram ework to c ommunicate  with JAWS  until JAW S is shut'
  158       + CRLF  + 'down a nd restart ed.  Pleas e restart  JAWS at th is time.';
  159  
  160     DLL_VERS ION_ERROR  = ERROR_IN TRO +
  161       'The A ccessibili ty Framewo rk is at v ersion %s,  but the r equired JA WS' + CRLF
  162       + 'sup port files  are only  at version  %s.  The  new suppor t files sh ould have'
  163       + CRLF  + 'been r eleased wi th the lat est versio n of the s oftware yo u are curr ently'
  164       + CRLF  + 'runnin g.  The Ac cessibilit y Framewor k will not  be able t o communic ate'
  165       + CRLF  + 'with J AWS until  these supp ort files  are instal led.  Plea se contact  your'
  166       + CRLF  + 'system  administr ator for a ssistance. ';
  167  
  168     JAWS_AUT O_NOT_RUNN ING = ERRO R_INTRO +
  169       'The A ccessibili ty Framewo rk was una ble to ide ntify a ru nning inst ance of JA WS.'
  170       + ' If  you are r unning JAW S ' + JAWS _REQUIRED_ VERSION +  ' or later  please '
  171       + 'ver ify your s hortcut co ntains the  JAWS exec utable nam e' + CRLF  + CRLF +
  172       'Examp le: /SCREA DER:JAWS A pplication  Name.exe. ' + CRLF +
  173       'If yo u do not h ave access  to update  the %s sh ortcut, pl ease conta ct your lo cal '
  174       + ' su pport/help  personnel .' + CRLF  +
  175       'This  message bo x will aut omatically  close aft er 30 seco nds';
  176  
  177     JAWS_NOT _RUNNING =  ERROR_INT RO +
  178       'The A ccessibili ty Framewo rk was una ble to ide ntify a ru nning inst ance of JA WS.'
  179       + ' Th e Accessib ility Fram ework will  not be ab le to comm unicate' +
  180       'with  JAWS until  the corre ct JAWS ap plication  name is pa ssed into  the shortc ut for %s  .'
  181       + CRLF  + CRLF +  '/SCREADER =:%s is no t running  ' + CRLF +
  182       'If yo u do not h ave access  to update  the %s sh ortcut, pl ease conta ct your lo cal '
  183       + ' su pport/help  personnel .' + CRLF  +
  184       'This  message bo x will aut omatically  close aft er 30 seco nds';
  185  
  186     JAWS_ERR OR_VERSION  = 1;
  187     JAWS_ERR OR_FILE_IO  = 2;
  188     JAWS_ERR OR_USER_PR OBLEM = 3;
  189     DLL_ERRO R_VERSION  = 4;
  190     JAWS_ERR OR_COUNT =  4;
  191     JAWS_REL OAD_DELAY  = 500;
  192     MB_TIMED OUT = 3200 0;
  193  
  194   var
  195     JAWSErro rMessage:  array [1 . . JAWS_ERR OR_COUNT]  of string  = (
  196       JAWS_V ERSION_ERR OR,
  197       JAWS_F ILE_ERROR,
  198       JAWS_U SER_MISSMA TCH_ERROR,
  199       DLL_VE RSION_ERRO R
  200     );
  201  
  202     JAWSErro rsShown: a rray [1 ..  JAWS_ERRO R_COUNT] o f Boolean  = (
  203       FALSE,
  204       FALSE,
  205       FALSE,
  206       FALSE
  207     );
  208  
  209   type
  210     TJAWSSay String = f unction(St ringToSpea k: PChar;  Interrupt:  BOOL)
  211       : BOOL ; stdcall;
  212     TJAWSRun Script = f unction(Sc riptName:  PChar): BO OL; stdcal l;
  213  
  214     TStartup ID = recor d
  215       Handle : HWND;
  216       Instan ceID: Inte ger;
  217       MsgID:  Integer;
  218     end;
  219  
  220     tCompile File = rec ord
  221       FileNa me: String ;
  222       Compil ed: Boolea n;
  223       Compil er: String ;
  224       Depend entFile: A rray of tC ompileFile ;
  225       functi on Compile File(var R tnMsg: Str ing): Bool ean;
  226     end;
  227  
  228     TJawsRec ord = reco rd
  229       Versio n: Double;
  230       Compil er: string ;
  231       Defaul tScriptDir : String;
  232       UserSc riptDir: S tring;
  233       FDicti onaryFileN ame: strin g;
  234       FConfi gFile: str ing;
  235       FKeyMa pFile: str ing;
  236       FKeyMa pINIFile:  TINIFile;
  237       FKeyMa pINIFileMo dified: Bo olean;
  238       FAssig nedKeys: T StringList ;
  239       FConfi gINIFile:  TINIFile;
  240       FConfi gINIFileMo dified: Bo olean;
  241       FDicti onaryFile:  TStringLi st;
  242       FDicti onaryFileM odified: B oolean;
  243     end;
  244  
  245     TJAWSMan ager = cla ss
  246     strict p rivate
  247       FRequi redFilesFo und: Boole an;
  248       FMainF orm: TfrmV A508Hidden JawsMainWi ndow;
  249       FWasSh utdown: Bo olean;
  250       FJAWSF ileError:  string;
  251       FHidde nJaws: TFo rm;
  252       // FRo otScriptFi leName: st ring;
  253       // FRo otScriptAp pFileName:  string;
  254       JAWSAP I: IJawsAp i;
  255     private
  256       fCompo nentCallBa ckProc: TC omponentDa taRequestP roc;
  257       fScrip tFilesChan ged: Boole an;
  258       proced ure ShutDo wn;
  259       proced ure MakeFi leWritable (FileName:  string);
  260       proced ure Launch MasterAppl ication;
  261       proced ure KillIN IFiles(Sen der: TObje ct);
  262       proced ure Reload Configurat ion;
  263       proced ure Ensure Window;
  264     public
  265       constr uctor Crea te;
  266       destru ctor Destr oy; overri de;
  267       class  procedure  ShowError( ErrorNumbe r: Integer ); overloa d;
  268       class  procedure  ShowError( ErrorNumbe r: Integer ;
  269         data : array of  const); o verload;
  270       // cla ss functio n GetPathF romJAWS(Pa thID: Inte ger;
  271       // DoL owerCase:  boolean =  TRUE): str ing;
  272       class  function G etJAWSWind ow: HWND;
  273       class  function I sRunning(H ighVersion , LowVersi on: Word):  BOOL;
  274       class  function F indJaws():  HWND;
  275       functi on Initial ize(Compon entCallBac kProc: TCo mponentDat aRequestPr oc): BOOL;
  276       proced ure SendCo mponentDat a(WindowHa ndle: HWND ; DataStat us: LongIn t;
  277         Capt ion, Value , data, Co ntrolType,  State, In structions ,
  278         Item Instructio ns: PChar) ;
  279       proced ure SpeakT ext(Text:  PChar);
  280       proced ure Regist erCustomBe havior(Bef ore, After : string;  Action: In teger);
  281       class  function J AWSVersion OK: Boolea n;
  282       class  function J AWSTalking 2CurrentUs er: Boolea n;
  283       functi on FileErr orExists:  Boolean;
  284       proced ure GetScr iptFiles(v ar info: T FileInfoAr ray);
  285       proper ty Require dFilesFoun d: Boolean  read FReq uiredFiles Found;
  286       proper ty MainFor m: TfrmVA5 08HiddenJa wsMainWind ow read FM ainForm;
  287       proper ty ScriptF ilesChange d: Boolean  read fScr iptFilesCh anged;
  288     end;
  289  
  290   function M essageBoxT imeOutW(HW ND: HWND;  lpText: PW ideChar; l pCaption:  PWideChar;
  291     uType: U INT; wLang uageId: Wo rd; dwMill iseconds:  DWORD): In teger; std call;
  292     external  user32 na me 'Messag eBoxTimeou tW';
  293   function M essageBoxT imeOutA(HW ND: HWND;  lpText: PC har; lpCap tion: PCha r;
  294     uType: U INT; wLang uageId: Wo rd; dwMill iseconds:  DWORD): In teger; std call;
  295     external  user32 na me 'Messag eBoxTimeou tA';
  296  
  297   var
  298     // ***** ********** ********** ********** ********** ********** ********** *
  299     // Archi ved Variab le
  300     // ***** ********** ********** ********** ********** ********** ********** *
  301     // DLLMe ssageID: U INT = 0;
  302  
  303     JAWSMana ger: TJAWS Manager =  nil;
  304     JawsReco rd: array  of TJawsRe cord;
  305     ScriptFi les: TFile InfoArray;
  306     JAWSHand le: HWND =  0;
  307     UserSpla sh: tSplas hTaskDialo g;
  308  
  309   {$REGION ' Add export  methods t o this reg ion'}
  310  
  311     // ***** ********** ********** ********** ********** ********** ********** *
  312     // Ensur e the JAWS manager ob ject exist
  313     // ***** ********** ********** ********** ********** ********** ********** *
  314   procedure  EnsureMana ger;
  315   begin
  316     if not a ssigned(JA WSManager)  then
  317       JAWSMa nager := T JAWSManage r.Create;
  318   end;
  319  
  320   // ******* ********** ********** ********** ********** ********** *********
  321   // Checks  to see if  the screen  reader is  currently  running
  322   // ******* ********** ********** ********** ********** ********** *********
  323   function I sRunning(H ighVersion , LowVersi on: Word):  BOOL; std call;
  324   begin
  325     EnsureMa nager; //  need to pr eload the  directorie s
  326     Result : = TJAWSMan ager.IsRun ning(HighV ersion, Lo wVersion);
  327   end;
  328  
  329   function F indJaws():  BOOL; std call;
  330   begin
  331     EnsureMa nager; //  need to pr eload the  directorie s
  332     JAWSHand le := TJAW SManager.F indJaws;
  333     Result : = (JAWSHan dle <> 0);
  334   end;
  335  
  336   // ******* ********** ********** ********** ********** ********** *********
  337   // Execute d after Is Running re turns TRUE , when the  DLL is ac cepted
  338   // as the  screen rea der of cho ice
  339   // ******* ********** ********** ********** ********** ********** *********
  340   function I nitializeS ub(Compone ntCallBack Proc: TCom ponentData RequestPro c): BOOL;
  341   begin
  342     EnsureMa nager;
  343     UserSpla sh.TaskMax Prog := (3  + Length( ScriptFile s)) * Leng th(JawsRec ord) + 1;
  344     Result : = JAWSMana ger.Initia lize(Compo nentCallBa ckProc);
  345   end;
  346  
  347   function I nitialize( ComponentC allBackPro c: TCompon entDataReq uestProc)
  348     : BOOL;  stdcall;
  349   var
  350     VersionN um: string ;
  351     i, Force Num: Integ er;
  352   begin
  353     // Need  to make th readed
  354     UserSpla sh := nil;
  355  
  356     // If no t show tas k dialog
  357     ForceNum  := -1;
  358     if FindC ommandSwit ch('FORCEU PD') then
  359       ForceN um := 0
  360     else
  361     begin
  362       for i  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  363       begin
  364         Vers ionNum :=  FloatToStr (JawsRecor d[i].Versi on);
  365         if P os('.', Ve rsionNum)  > 0 then
  366           Ve rsionNum : = Copy(Ver sionNum, 1 , Pos('.',  VersionNu m) - 1);
  367         if F indCommand Switch('FO RCEUPD' +  VersionNum ) then
  368         begi n
  369           Fo rceNum :=  StrToIntDe f(VersionN um, 0);
  370           br eak;
  371         end;
  372       end;
  373     end;
  374  
  375     UserSpla sh := tSpl ashTaskDia log.Create (Initializ eSub, Comp onentCallB ackProc,
  376       LogInt erface.Act ive, Force Num);
  377     try
  378       if Log Interface. Active the n
  379         User Splash.Log Path := Lo gInterface .LogFile;
  380       UserSp lash.Show;
  381       Result  := UserSp lash.Retur nValue;
  382       if Res ult then
  383       begin
  384         JAWS Manager.En sureWindow ;
  385         JAWS Manager.La unchMaster Applicatio n;
  386         if J AWSManager .ScriptFil esChanged  then
  387         begi n
  388           JA WSManager. MainForm.C onfigReloa dNeeded;
  389         end;
  390       end;
  391  
  392     finally
  393       FreeAn dNil(UserS plash);
  394     end;
  395  
  396   end;
  397  
  398   // ******* ********** ********** ********** ********** ********** *********
  399   // Execute d when the  DLL is un loaded or  screen rea der is no  longer
  400   // needed
  401   // ******* ********** ********** ********** ********** ********** *********
  402   procedure  ShutDown;  stdcall;
  403   begin
  404     if assig ned(JAWSMa nager) the n
  405     begin
  406       JAWSMa nager.Shut Down;
  407       FreeAn dNil(JAWSM anager);
  408     end;
  409   end;
  410  
  411   // ******* ********** ********** ********** ********** ********** *********
  412   // Determi nes if con figuration  changes a re pending
  413   // ******* ********** ********** ********** ********** ********** *********
  414   function C onfigChang ePending:  Boolean; s tdcall;
  415   begin
  416     Result : = FALSE;
  417     if assig ned(JAWSMa nager) and  assigned( JAWSManage r.MainForm ) and
  418       (JAWSM anager.Mai nForm.Conf igChangePe nding) the n
  419       Result  := TRUE;
  420   end;
  421  
  422   // ******* ********** ********** ********** ********** ********** *********
  423   // Returns  Component  Data as r equested b y the scre en reader
  424   // ******* ********** ********** ********** ********** ********** *********
  425   procedure  ComponentD ata(Window Handle: HW ND; DataSt atus: Long Int = DATA _NONE;
  426     Caption:  PChar = n il; Value:  PChar = n il; data:  PChar = ni l;
  427     ControlT ype: PChar  = nil; St ate: PChar  = nil; In structions : PChar =  nil;
  428     ItemInst ructions:  PChar = ni l); stdcal l;
  429   begin
  430     EnsureMa nager;
  431     JAWSMana ger.SendCo mponentDat a(WindowHa ndle, Data Status, Ca ption, Val ue, data,
  432       Contro lType, Sta te, Instru ctions, It emInstruct ions);
  433   end;
  434  
  435   // ******* ********** ********** ********** ********** ********** *********
  436   // Instruc ts the Scr een Reader  to say th e specifie d text
  437   // ******* ********** ********** ********** ********** ********** *********
  438   procedure  SpeakText( Text: PCha r); stdcal l;
  439   begin
  440     EnsureMa nager;
  441     JAWSMana ger.SpeakT ext(Text);
  442   end;
  443  
  444   // ******* ********** ********** ********** ********** ********** *********
  445   // Registe rs any cus tom behavi or
  446   // ******* ********** ********** ********** ********** ********** *********
  447   procedure  RegisterCu stomBehavi or(Behavio rType: Int eger; Befo re, After:  PChar);
  448   begin
  449     EnsureMa nager;
  450     JAWSMana ger.Regist erCustomBe havior(Bef ore, After , Behavior Type);
  451   end;
  452  
  453   {$ENDREGIO N}
  454   {$REGION ' Add TJAWSM anager met hods to th is region' }
  455  
  456   // ******* ********** ********** ********** ********** ********** *********
  457   // Makes a  file writ able
  458   // ******* ********** ********** ********** ********** ********** *********
  459   procedure  TJAWSManag er.MakeFil eWritable( FileName:  string);
  460   const
  461   {$WARNINGS  OFF} // D on't care  about plat form speci fic warnin g
  462     NON_WRIT ABLE_FILE_ ATTRIB = f aReadOnly  or faHidde n;
  463   {$WARNINGS  ON}
  464     WRITABLE _FILE_ATTR IB = faAny File and ( not NON_WR ITABLE_FIL E_ATTRIB);
  465  
  466   var
  467     Attrib:  Integer;
  468   begin
  469   {$WARNINGS  OFF} // D on't care  about plat form speci fic warnin g
  470     Attrib : = FileGetA ttr(FileNa me);
  471   {$WARNINGS  ON}
  472     if (Attr ib and NON _WRITABLE_ FILE_ATTRI B) <> 0 th en
  473     begin
  474       Attrib  := Attrib  and WRITA BLE_FILE_A TTRIB;
  475   {$WARNINGS  OFF} // D on't care  about plat form speci fic warnin g
  476       if Fil eSetAttr(F ileName, A ttrib) <>  0 then
  477   {$WARNINGS  ON}
  478         FJAW SFileError  := 'Could  not chang e read-onl y attribut e of file  "' +
  479           Fi leName + ' "';
  480  
  481     end;
  482   end;
  483  
  484   // ******* ********** ********** ********** ********** ********** *********
  485   // Create  method for  the JawsM anager
  486   // ******* ********** ********** ********** ********** ********** *********
  487   constructo r TJAWSMan ager.Creat e;
  488   const
  489     COMPILER _FILENAME  = 'scompil e.exe';
  490     // JAWS_ APP_NAME =  'VA508APP ';
  491  
  492     function  ContinueT oLoad(Temp SubDir: st ring): Boo lean;
  493     Var
  494       TempUS Dir, TempD SDir, Path ToCheck: S tring;
  495       idx1,  idx2: Inte ger;
  496     begin
  497       // Def ault Scrip t
  498       TempDS Dir := Get SpecialFol derPath(CS IDL_COMMON _APPDATA)  +
  499         JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(TempSub Dir);
  500  
  501       // Use r Script
  502       TempUS Dir := Get SpecialFol derPath(CS IDL_APPDAT A) +
  503         JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(TempSub Dir);
  504  
  505       // Scr ipt Folder
  506       PathTo Check := ' ';
  507       idx1 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, Temp USDir);
  508       idx2 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, Temp DSDir);
  509  
  510       PathTo Check := C opy(TempUS Dir, 1, id x1 - 1) +  Copy(TempD SDir, idx2 , MaxInt);
  511  
  512       Result  := Direct oryExists( PathToChec k);
  513       // Che ck to see  if directo ry exist ( they have  ran jaws)
  514  
  515     end;
  516  
  517   // ******* ********** ********** ********** ********** ********** *********
  518   // Load th e jaws dir ectories v ia regestr ies
  519   // ******* ********** ********** ********** ********** ********** *********
  520     procedur e LoadJaws Directorie s;
  521     var
  522       reg: T Registry;
  523       keys:  TStringLis t;
  524       i: Int eger;
  525       key, D ir, SubDir , Version:  string;
  526     begin
  527       keys : = TStringL ist.Create ;
  528       try
  529         reg  := TRegist ry.Create( KEY_READ o r KEY_WOW6 4_64KEY);
  530         try
  531           re g.RootKey  := HKEY_LO CAL_MACHIN E;
  532           re g.OpenKey( JAWS_REGRO OT, FALSE) ;
  533           re g.GetKeyNa mes(keys);
  534           fo r i := 0 t o keys.Cou nt - 1 do
  535           be gin
  536              Version :=  keys[i];
  537              key := JAW S_REGROOT  + '\' + ke ys[i] + '\ ';
  538              reg.CloseK ey;
  539              SubDir :=  Version +  '\' + JAWS _SCRIPTDIR ;
  540              if reg.Ope nKey(key,  FALSE) the n
  541              begin
  542                Dir := L owerCase(r eg.ReadStr ing(JAWS_I NSTALL_DIR ECTORY_VAR ));
  543                LogInter face.LogTe xt('Jaws F ound', 'Ve rsion: ' +  Version +  #13#10 +
  544                  'Direc tory: ' +  Dir);
  545  
  546                Dir := A ppendBackS lash(Dir)  + COMPILER _FILENAME;
  547                if FileE xists(Dir)  and Conti nueToLoad( SubDir) th en
  548                begin
  549                  SetLen gth(JawsRe cord, Leng th(JawsRec ord) + 1);
  550                  JawsRe cord[high( JawsRecord )].Version  :=
  551                    StrT ofloatDef( Version, - 1);
  552                  JawsRe cord[high( JawsRecord )].Compile r := Dir;
  553                  Dir :=  GetSpecia lFolderPat h(CSIDL_CO MMON_APPDA TA) +
  554                    JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(SubDir) ;
  555                  JawsRe cord[high( JawsRecord )].Default ScriptDir  := Dir;
  556                  Dir :=  GetSpecia lFolderPat h(CSIDL_AP PDATA) +
  557                    JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(SubDir) ;
  558                  JawsRe cord[high( JawsRecord )].UserScr iptDir :=  Dir;
  559                end;
  560              end;
  561  
  562           en d;
  563         fina lly
  564           re g.free;
  565         end;
  566       finall y
  567         keys .free;
  568       end;
  569     end;
  570  
  571   // ******* ********** ********** ********** ********** ********** *********
  572   // Ensure  all the re quired fil es are pre sent in th e vista fo lder
  573   // ******* ********** ********** ********** ********** ********** *********
  574     procedur e FindJAWS RequiredFi les;
  575     var
  576       path:  string;
  577       i: Int eger;
  578       LogTxt : string;
  579     begin
  580       SetLen gth(path,  MAX_PATH);
  581       SetLen gth(path,  GetModuleF ileName(HI nstance, P Char(path) , Length(p ath)));
  582       path : = ExtractF ilePath(pa th);
  583       path : = AppendBa ckSlash(pa th);
  584       // loo k for the  script fil es in the  same direc tory as th is DLL
  585  
  586       FRequi redFilesFo und := TRU E;
  587  
  588       // Loo k up the f iles
  589       if Len gth(Script Files) = 0  then
  590         GetS criptFiles (ScriptFil es);
  591  
  592       if Len gth(Script Files) > 0  then
  593       begin
  594         LogI nterface.L ogText(' S cripts  ',
  595           'F older:' +  ExtractFil ePath(Scri ptFiles[0] .FileName) )
  596       end
  597       else
  598         LogI nterface.L ogText(' S cripts  ',
  599           '! ! No files  to lookup  !! Please  check the  VA508Scri ptList.INI ');
  600  
  601       // now  ensure th at the req uired file s are ther e
  602       for i  := low(Scr iptFiles)  to high(Sc riptFiles)  do
  603       begin
  604         LogT xt := 'Fil e Name:' +  ExtractFi leName(Scr iptFiles[i ].FileName );
  605         if S criptFiles [i].Requir ed then
  606         begi n
  607           Lo gTxt := Lo gTxt + #13 #10 + 'Req uired: YES ';
  608           if  not Scrip tFiles[i]. Exist then
  609           be gin
  610              FRequiredF ilesFound  := FALSE;
  611              LogTxt :=  LogTxt + # 13#10 + 'F ile Found:  NO';
  612              // break;
  613           en d
  614           el se
  615              LogTxt :=  LogTxt + # 13#10 + 'F ile Found:  YES';
  616         end
  617         else
  618         begi n
  619           Lo gTxt := Lo gTxt + #13 #10 + 'Req uired: NO' ;
  620           if  not Scrip tFiles[i]. Exist then
  621              LogTxt :=  LogTxt + # 13#10 + 'F ile Found:  NO'
  622           el se
  623              LogTxt :=  LogTxt + # 13#10 + 'F ile Found:  YES';
  624  
  625         end;
  626  
  627         LogI nterface.L ogText(Int ToStr(i +  1) + '/' +  IntToStr( Length(Scr iptFiles)
  628           -  1), LogTxt );
  629       end;
  630     end;
  631  
  632   begin
  633     SetLengt h(JawsReco rd, 0);
  634     LoadJaws Directorie s;
  635     if Lengt h(JawsReco rd) > 0 th en
  636       FindJA WSRequired Files;
  637     if not F RequiredFi lesFound t hen
  638       ShowEr ror(JAWS_E RROR_FILE_ IO, ['Requ ired files  missing'] )
  639   end;
  640  
  641   // ******* ********** ********** ********** ********** ********** *********
  642   // Destroy  method fo r the Jaws Manager
  643   // ******* ********** ********** ********** ********** ********** *********
  644   destructor  TJAWSMana ger.Destro y;
  645   begin
  646     SetLengt h(JawsReco rd, 0);
  647     ShutDown ;
  648     inherite d;
  649   end;
  650  
  651   // ******* ********** ********** ********** ********** ********** *********
  652   // Returns  if an err or has bee n captured
  653   // ******* ********** ********** ********** ********** ********** *********
  654   function T JAWSManage r.FileErro rExists: B oolean;
  655   begin
  656     Result : = (FJAWSFi leError <>  '');
  657   end;
  658  
  659   // ******* ********** ********** ********** ********** ********** *********
  660   // Fills o ut the fil e array wi th sciprts  to be mov ed over
  661   // ******* ********** ********** ********** ********** ********** *********
  662   procedure  TJAWSManag er.GetScri ptFiles(va r info: TF ileInfoArr ay);
  663   var
  664     ScriptsF ile: TINIF ile;
  665     path, Sc riptsFileN ame, TmpSt r: string;
  666     Scripts:  TStringLi st;
  667     i, X, Y:  Integer;
  668  
  669     function  FindScrip tFileLocat ion(aBaseP ath, aFile Name: stri ng): Strin g;
  670     var
  671       Script Dir: Strin g;
  672     begin
  673       aBaseP ath := App endBackSla sh(aBasePa th);
  674       Script Dir := Jaw s_Script_F older;
  675       Script Dir := App endBackSla sh(ScriptD ir);
  676       if Fil eExists(aB asePath +  ScriptDir  + aFileNam e) then
  677         Resu lt := aBas ePath + Sc riptDir
  678       else i f FileExis ts(aBasePa th + aFile Name) then
  679         Resu lt := aBas ePath
  680       else
  681         Resu lt := '';
  682     end;
  683  
  684     function  LoadInfoR ec(aPatchD ir, aFileN ame, Value : String):  TFileInfo ;
  685     var
  686       TmpCom pare: stri ng;
  687       FoundP ath: Strin g;
  688       TmpStr Lst: TStri ngList;
  689       i: Int eger;
  690     begin
  691       SetLen gth(Result .Add_To_Us es, 0);
  692       FoundP ath := Fin dScriptFil eLocation( aPatchDir,  aFileName );
  693       if Fou ndPath <>  '' then
  694       begin
  695         Resu lt.FileNam e := Appen dBackSlash (FoundPath ) + aFileN ame;
  696         Resu lt.Exist : = FileExis ts(Result. FileName);
  697       end
  698       else
  699       begin
  700         Resu lt.FileNam e := aFile Name;
  701         Resu lt.Exist : = FALSE;
  702       end;
  703  
  704       TmpCom pare := Pi ece(Value,  '|', 1);
  705       if Upp erCase(Tmp Compare) =  'JCPRIOR'  then
  706         Resu lt.Compare Type := jc Prior
  707       else i f UpperCas e(TmpCompa re) = 'JCI NI' then
  708         Resu lt.Compare Type := jc INI
  709       else i f UpperCas e(TmpCompa re) = 'JCL INEITEMS'  then
  710         Resu lt.Compare Type := jc LineItems
  711       else i f UpperCas e(TmpCompa re) = 'JCV ERSION' th en
  712         Resu lt.Compare Type := jc Version
  713       else i f UpperCas e(TmpCompa re) = 'JCS CRIPTMERGE ' then
  714         Resu lt.Compare Type := jc ScriptMerg e
  715       else i f UpperCas e(TmpCompa re) = 'JCI NIMRG' the n
  716         Resu lt.Compare Type := jc INIMRG
  717       else i f UpperCas e(TmpCompa re) = 'JCL INEITEMSMR G' then
  718         Resu lt.Compare Type := jc LineItemsM RG;
  719  
  720       TmpCom pare := Pi ece(Value,  '|', 2);
  721       if Upp erCase(Tmp Compare) =  'TRUE' th en
  722         Resu lt.Require d := TRUE
  723       else i f UpperCas e(TmpCompa re) = 'FAL SE' then
  724         Resu lt.Require d := FALSE ;
  725  
  726       TmpCom pare := Pi ece(Value,  '|', 3);
  727       if Upp erCase(Tmp Compare) =  'TRUE' th en
  728         Resu lt.Compile  := TRUE
  729       else i f UpperCas e(TmpCompa re) = 'FAL SE' then
  730         Resu lt.Compile  := FALSE;
  731  
  732       TmpCom pare := Pi ece(Value,  '|', 4);
  733       if Tri m(TmpCompa re) <> ''  then
  734       begin
  735         TmpC ompare :=  Piece(TmpC ompare, '[ ', 2);
  736         TmpC ompare :=  Piece(TmpC ompare, '] ', 1);
  737         TmpS trLst := T StringList .Create;
  738         try
  739           Tm pStrLst.Te xt := TmpC ompare;
  740           fo r i := 0 t o TmpStrLs t.Count -  1 do
  741           be gin
  742              SetLength( Result.Add _To_Uses,  Length(Res ult.Add_To _Uses) + 1 );
  743              Result.Add _To_Uses[H igh(Result .Add_To_Us es)].FileN ame :=
  744                TmpStrLs t.Strings[ i];
  745           en d;
  746         fina lly
  747           Tm pStrLst.fr ee;
  748         end;
  749       end;
  750  
  751     end;
  752  
  753     function  LoadOverW rites(Sect ionName: S tring): Bo olean;
  754     var
  755       i, X:  Integer;
  756       FileNa me, extNam e: String;
  757     begin
  758       if Scr iptsFile.S ectionExis ts(Section Name) then
  759       begin
  760         Resu lt := TRUE ;
  761         Scri ptsFile.Re adSectionV alues(Sect ionName, S cripts);
  762         for  i := 0 to  Scripts.Co unt - 1 do
  763         begi n
  764           //  if script  is named  after the  app then r eplace
  765           Fi leName :=  Piece(Extr actFileNam e(Scripts. Names[i]),  '.', 1);
  766           ex tName := P iece(Extra ctFileName (Scripts.N ames[i]),  '.', 2);
  767           //  Section n ame should  be the ap plications  name
  768           if  UpperCase (FileName)  = UpperCa se(Section Name) then
  769           be gin
  770              if Pos('MR G', UpperC ase(Piece( Scripts.Va lues[Scrip ts.Names[i ]], '|',
  771                1))) = 0  then
  772              begin
  773                for X :=  Low(info)  to High(i nfo) do
  774                begin
  775                  if (Up perCase(Pi ece(Extrac tFileName( info[X].Fi leName), ' .', 1))
  776                    = Up perCase(JA WS_APP_NAM E)) and
  777                    (Upp erCase(Pie ce(Extract FileName(i nfo[X].Fil eName), '. ', 2))
  778                    = Up perCase(ex tName)) th en
  779                  begin
  780                    // o verwrite i ts corrisp onding va5 08app file
  781                    info [X] := Loa dInfoRec(p ath, Scrip ts.Names[i ],
  782                      Sc ripts.Valu es[Scripts .Names[i]] );
  783                    brea k;
  784                  end;
  785                end;
  786              end
  787              else
  788              begin
  789                SetLengt h(info, Le ngth(info)  + 1);
  790                info[Hig h(info)] : = LoadInfo Rec(path,  Scripts.Na mes[i],
  791                  Script s.Values[S cripts.Nam es[i]]);
  792              end;
  793           en d
  794           el se
  795           be gin
  796              SetLength( info, Leng th(info) +  1);
  797              info[High( info)] :=  LoadInfoRe c(path, Sc ripts.Name s[i],
  798                Scripts. Values[Scr ipts.Names [i]]);
  799           en d;
  800         end;
  801       end
  802       else
  803         Resu lt := FALS E;
  804     end;
  805  
  806   begin
  807     SetLengt h(path, MA X_PATH);
  808     SetLengt h(path, Ge tModuleFil eName(HIns tance, PCh ar(path),  Length(pat h)));
  809     path :=  ExtractFil ePath(path );
  810     path :=  AppendBack Slash(path );
  811     ScriptsF ileName :=  FindScrip tFileLocat ion(path,  JAWS_SCRIP T_LIST);
  812     if Scrip tsFileName  <> '' the n
  813     begin
  814       Script sFileName  := AppendB ackSlash(S criptsFile Name) + JA WS_SCRIPT_ LIST;
  815       if Fil eExists(Sc riptsFileN ame) then
  816       begin
  817         Scri ptsFile :=  TINIFile. Create(Scr iptsFileNa me);
  818         Scri pts := TSt ringList.C reate;
  819         try
  820           Se tLength(in fo, 0);
  821           Sc riptsFile. ReadSectio nValues('S CRIPTS', S cripts);
  822           fo r i := 0 t o Scripts. Count - 1  do
  823           be gin
  824              SetLength( info, Leng th(info) +  1);
  825              info[High( info)] :=  LoadInfoRe c(path, Sc ripts.Name s[i],
  826                Scripts. Values[Scr ipts.Names [i]]);
  827           en d;
  828  
  829           //  Now check  for custo m overwrit es
  830           //  first loo k for gene ral App
  831           Tm pStr := Pi ece(Extrac tFileName( ParamStr(0 )), '.', 1 );
  832           Lo adOverWrit es(TmpStr) ;
  833  
  834           //  second lo ok for a s pecific ve rsion
  835           Tm pStr := Tm pStr + '|'  + FileVer sionValue( ParamStr(0 ),
  836              FILE_VER_F ILEVERSION );
  837           Lo adOverWrit es(TmpStr) ;
  838  
  839         fina lly
  840           Sc riptsFile. free;
  841         end;
  842       end;
  843     end;
  844  
  845     // Now u pdate the  dependenci es
  846     for i :=  Low(info)  to High(i nfo) do
  847     begin
  848       if Len gth(info[i ].Add_To_U ses) > 0 t hen
  849       begin
  850         for  X := Low(i nfo[i].Add _To_Uses)  to High(in fo[i].Add_ To_Uses) d o
  851         begi n
  852           fo r Y := Low (info) to  High(info)  do
  853           be gin
  854              if UpperCa se(Extract FileName(i nfo[Y].Fil eName))
  855                = UpperC ase(info[i ].Add_To_U ses[X].Fil eName) the n
  856              begin
  857                SetLengt h(info[Y]. Dependenci es, Length (info[Y].D ependencie s) + 1);
  858                info[Y]. Dependenci es[High(in fo[Y].Depe ndencies)] .FileName  :=
  859                  Extrac tFileName( info[i].Fi leName);
  860                break;
  861              end;
  862           en d;
  863         end;
  864         SetL ength(info [i].Add_To _Uses, 0);
  865       end;
  866     end;
  867  
  868   end;
  869  
  870   // ******* ********** ********** ********** ********** ********** *********
  871   // Return  the handle  of the Ja ws applica tion
  872   // ******* ********** ********** ********** ********** ********** *********
  873   class func tion TJAWS Manager.Ge tJAWSWindo w: HWND;
  874   const
  875     VISIBLE_ WINDOW_CLA SS: PChar  = 'JFWUI2' ;
  876     VISIBLE_ WINDOW_TIT LE: PChar  = 'JAWS';
  877     VISIBLE_ WINDOW_TIT LE2: PChar  = 'Remote  JAWS';
  878   begin
  879     if JAWSH andle = 0  then
  880     begin
  881       JAWSHa ndle := Fi ndWindow(V ISIBLE_WIN DOW_CLASS,  VISIBLE_W INDOW_TITL E);
  882       if JAW SHandle =  0 then
  883         JAWS Handle :=  FindWindow (VISIBLE_W INDOW_CLAS S, VISIBLE _WINDOW_TI TLE2);
  884       if JAW SHandle =  0 then
  885         JAWS Handle :=  FindJaws() ;
  886     end;
  887  
  888     Result : = JAWSHand le;
  889   end;
  890  
  891   // ******* ********** ********** ********** ********** ********** *********
  892   // Return  the handle  of an app lication
  893   // ******* ********** ********** ********** ********** ********** *********
  894   function F indHandle( exeFileNam e: string) : HWND;
  895   type
  896     TEInfo =  record
  897       PID: D WORD;
  898       HWND:  THandle;
  899     end;
  900  
  901     function  CallBack( Wnd: DWORD ; var EI:  TEInfo): B OOL; stdca ll;
  902     var
  903       PID: D WORD;
  904     begin
  905       GetWin dowThreadP rocessID(W nd, @PID); ;
  906       Result  := (PID < > EI.PID)  and (GetPa rent(Wnd)  <> 0);
  907       // Res ult := (PI D <> EI.PI D) or (not  IsWindowV isible(Wnd )) or
  908       // (no t IsWindow Enabled(Wn d));
  909       if not  Result th en
  910         EI.H WND := Wnd ;
  911     end;
  912  
  913   var
  914     Continue Loop: BOOL ;
  915     FSnapsho tHandle: T Handle;
  916     FProcess Entry32: T ProcessEnt ry32;
  917     EInfo: T EInfo;
  918   begin
  919     Result : = 0;
  920     FSnapsho tHandle :=  CreateToo lhelp32Sna pshot(TH32 CS_SNAPPRO CESS, 0);
  921     FProcess Entry32.dw Size := Si zeOf(FProc essEntry32 );
  922     Continue Loop := Pr ocess32Fir st(FSnapsh otHandle,  FProcessEn try32);
  923  
  924     while In teger(Cont inueLoop)  <> 0 do
  925     begin
  926       if ((U pperCase(E xtractFile Name(FProc essEntry32 .szExeFile ))
  927         = Up perCase(ex eFileName) ) or (Uppe rCase(FPro cessEntry3 2.szExeFil e)
  928         = Up perCase(ex eFileName) )) then
  929       begin
  930         EInf o.PID := F ProcessEnt ry32.th32P rocessID;
  931         EInf o.HWND :=  0;
  932         Enum Windows(@C allBack, I nteger(@EI nfo));
  933         Resu lt := EInf o.HWND;
  934       end;
  935       Contin ueLoop :=  Process32N ext(FSnaps hotHandle,  FProcessE ntry32);
  936     end;
  937     CloseHan dle(FSnaps hotHandle) ;
  938   end;
  939  
  940   // ******* ********** ********** ********** ********** ********** *********
  941   // Is jaws  running?  and if so  set the re turn var t o the hand le
  942   // ******* ********** ********** ********** ********** ********** *********
  943   class func tion TJAWS Manager.Fi ndJaws():  HWND;
  944   const
  945     ORIGNIAL _JAWS_EXE  = 'jfw.exe ';
  946   var
  947     JawsPara m, ErrMsg:  String;
  948     reg: TRe gistry;
  949     CanConti nue: Boole an;
  950   begin
  951     // assum e its not  running
  952     Result : = 0;
  953  
  954     // Allow  to turn o ff jaws if  not wante d
  955     FindComm andSwitch( 'SCREADER' , JawsPara m);
  956     CanConti nue := not (UpperCase (JawsParam ) = 'NONE' );
  957  
  958     if not C anContinue  then
  959       LogInt erface.Log Text('Jaws  Run  ',
  960         'Jaw s Framewor k explicti ly turnded  off via S CREADER pa rameter');
  961  
  962     // check  for the r egistry
  963     if CanCo ntinue the n
  964     begin
  965       // che ck if JAWS  has been  installed  by looking  at the re gistry
  966       reg :=  TRegistry .Create(KE Y_READ or  KEY_WOW64_ 64KEY);
  967       try
  968         reg. RootKey :=  HKEY_LOCA L_MACHINE;
  969         CanC ontinue :=  reg.KeyEx ists(JAWS_ REGROOT);
  970       finall y
  971         reg. free;
  972       end;
  973     end;
  974  
  975     if not C anContinue  then
  976       LogInt erface.Log Text('Jaws  Run  ', ' Jaws regis try not fo und');
  977  
  978     // look  for the ex e (jaws 16  and up)
  979     if CanCo ntinue the n
  980     begin
  981       Result  := FindHa ndle(ORIGN IAL_JAWS_E XE);
  982  
  983       // can t find exp ected app  running so  look for  paramater
  984       if Res ult = 0 th en
  985       begin
  986         Jaws Param := ' ';
  987         Find CommandSwi tch('SCREA DER', Jaws Param);
  988         if T rim(JawsPa ram) <> ''  then
  989         begi n
  990           //  Look for  the parama ter exe
  991           Re sult := Fi ndHandle(J awsParam);
  992           if  Result =  0 then
  993           be gin
  994              // could n ot find th e paramete r exe runn ing
  995              ErrMsg :=  Format(JAW S_NOT_RUNN ING,
  996                [Extract FileName(A pplication .ExeName),  JawsParam ,
  997                ExtractF ileName(Ap plication. ExeName)]) ;
  998   {$IFDEF VE R180}
  999              MessageBox TimeOutA(A pplication .Handle, P Char(ErrMs g),
  1000                'JAWS Ac cessibilit y Detectio n Error',  MB_OK or M B_ICONERRO R or
  1001                MB_TASKM ODAL or MB _TOPMOST,  0, 30000);
  1002   {$ELSE}
  1003              MessageBox TimeOutW(A pplication .Handle, P Char(ErrMs g),
  1004                'JAWS Ac cessibilit y Detectio n Error',  MB_OK or M B_ICONERRO R or
  1005                MB_TASKM ODAL or MB _TOPMOST,  0, 30000);
  1006   {$ENDIF}
  1007              LogInterfa ce.LogText ('Jaws Run   ',
  1008                'Instanc e Name: !!  No runnin g instance s of JAWSf ound !!');
  1009  
  1010           en d
  1011           el se
  1012              LogInterfa ce.LogText ('Jaws Run   ', 'Inst ance Name:  ' + JawsP aram);
  1013         end
  1014         else
  1015         begi n
  1016           //  no parame ter and ex pected exe  is not ru nning
  1017   {$IFDEF VE R180}
  1018           Er rMsg := Fo rmat(JAWS_ AUTO_NOT_R UNNING,
  1019              [ExtractFi leName(App lication.E xeName),
  1020              ExtractFil eName(Appl ication.Ex eName)]);
  1021           Me ssageBoxTi meOutA(App lication.H andle, PCh ar(ErrMsg) ,
  1022              'JAWS Acce ssibility  Detection  Error', MB _OK or MB_ ICONERROR  or
  1023              MB_TASKMOD AL or MB_T OPMOST, 0,  30000);
  1024   {$ELSE}
  1025           Er rMsg := Fo rmat(JAWS_ AUTO_NOT_R UNNING,
  1026              [ExtractFi leName(App lication.E xeName),
  1027              ExtractFil eName(Appl ication.Ex eName)]);
  1028           Me ssageBoxTi meOutW(App lication.H andle, PCh ar(ErrMsg) ,
  1029              'JAWS Acce ssibility  Detection  Error', MB _OK or MB_ ICONERROR  or
  1030              MB_TASKMOD AL or MB_T OPMOST, 0,  30000);
  1031   {$ENDIF}
  1032         end;
  1033  
  1034         // s et the glo bal and re turn
  1035         JAWS Handle :=  Result;
  1036  
  1037       end
  1038       else
  1039         LogI nterface.L ogText('Ja ws Run  ',  'Instance  Name: ' +  ORIGNIAL_ JAWS_EXE);
  1040  
  1041     end;
  1042   end;
  1043  
  1044   // ******* ********** ********** ********** ********** ********** *********
  1045   // Initial  setup for  JawsManag er
  1046   // ******* ********** ********** ********** ********** ********** *********
  1047   function T JAWSManage r.Initiali ze(Compone ntCallBack Proc
  1048     : TCompo nentDataRe questProc) : BOOL;
  1049   var
  1050     DestPath , StatText , LogTxt:  string;
  1051     ScriptFi leChanges:  Boolean;
  1052     LastFile Updated: B oolean;
  1053     // Compi leCommands : TStringL ist;
  1054     CompileF iles: Arra y of tComp ileFile;
  1055     ArryCnt:  Integer;
  1056  
  1057     // ***** ********** ********** ********** ********** ********** ********** *
  1058     // Retri eves the J AWS_SCRIPT _VERSION f rom a scri pt file
  1059     // ***** ********** ********** ********** ********** ********** ********** *
  1060     function  GetVersio n(FileName : string):  Integer;
  1061     var
  1062       list:  TStringLis t;
  1063       p, i:  Integer;
  1064       line:  string;
  1065       workin g: Boolean ;
  1066     begin
  1067       Result  := 0;
  1068       list : = TStringL ist.Create ;
  1069       try
  1070         list .LoadFromF ile(FileNa me);
  1071         i :=  0;
  1072         work ing := TRU E;
  1073         whil e working  and (i < l ist.Count)  do
  1074         begi n
  1075           li ne := list [i];
  1076           p  := Pos('=' , line);
  1077           if  p > 0 the n
  1078           be gin
  1079              if Trim(Co py(line, 1 , p - 1))  = JAWS_SCR IPT_VERSIO N then
  1080              begin
  1081                line :=  Trim(Copy( line, p +  1, MaxInt) );
  1082                if Copy( line, Leng th(line),  1) = ',' t hen
  1083                  delete (line, Len gth(line),  1);
  1084                Result : = StrToInt Def(line,  0);
  1085                working  := FALSE;
  1086              end;
  1087           en d;
  1088           In c(i);
  1089         end;
  1090       finall y
  1091         list .free;
  1092       end;
  1093     end;
  1094  
  1095   // ******* ********** ********** ********** ********** ********** *********
  1096   // Compare s versions  between t wo script  files
  1097   // ******* ********** ********** ********** ********** ********** *********
  1098     function  VersionDi fferent(Fr omFile, To File: stri ng): Boole an;
  1099     var
  1100       FromVe rsion, ToV ersion: In teger;
  1101     begin
  1102       FromVe rsion := G etVersion( FromFile);
  1103       ToVers ion := Get Version(To File);
  1104       Result  := (FromV ersion > T oVersion);
  1105     end;
  1106  
  1107   // ******* ********** ********** ********** ********** ********** *********
  1108   // Determi nes if a l ine From F romFile is  missing i n the ToFi le
  1109   // ******* ********** ********** ********** ********** ********** *********
  1110     function  LineItemU pdateNeede d(FromFile , ToFile:  string): B oolean;
  1111     var
  1112       fromLi st, toList : TStringL ist;
  1113       i, idx : Integer;
  1114       line:  string;
  1115     begin
  1116       Result  := FALSE;
  1117       fromLi st := TStr ingList.Cr eate;
  1118       toList  := TStrin gList.Crea te;
  1119       try
  1120         from List.LoadF romFile(Fr omFile);
  1121         toLi st.LoadFro mFile(ToFi le);
  1122         for  i := 0 to  fromList.C ount - 1 d o
  1123         begi n
  1124           li ne := from List[i];
  1125           if  Trim(line ) <> '' th en
  1126           be gin
  1127              idx := toL ist.IndexO f(line);
  1128              if idx < 0  then
  1129              begin
  1130                Result : = TRUE;
  1131                break;
  1132              end;
  1133           en d;
  1134         end;
  1135       finall y
  1136         toLi st.free;
  1137         from List.free;
  1138       end;
  1139     end;
  1140  
  1141   // ******* ********** ********** ********** ********** ********** *********
  1142   // Determi nes if an  INI value  from FromF ile is mis sing in th e ToFile
  1143   // ******* ********** ********** ********** ********** ********** *********
  1144     function  INIUpdate Needed(Fro mFile, ToF ile: strin g): Boolea n;
  1145     var
  1146       FromIN IFile, ToI NIFile: TI NIFile;
  1147       Sectio ns, Values : TStringL ist;
  1148       i, j:  Integer;
  1149       sectio n, key, va l1, val2:  string;
  1150     begin
  1151       Result  := FALSE;
  1152       Sectio ns := TStr ingList.Cr eate;
  1153       Values  := TStrin gList.Crea te;
  1154       try
  1155         From INIFile :=  TINIFile. Create(Fro mFile);
  1156         try
  1157           To INIFile :=  TINIFile. Create(ToF ile);
  1158           tr y
  1159              FromINIFil e.ReadSect ions(Secti ons);
  1160              for i := 0  to Sectio ns.Count -  1 do
  1161              begin
  1162                section  := Section s[i];
  1163                FromINIF ile.ReadSe ctionValue s(section,  Values);
  1164                for j :=  0 to Valu es.Count -  1 do
  1165                begin
  1166                  key :=  Values.Na mes[j];
  1167                  val1 : = Values.V alueFromIn dex[j];
  1168                  val2 : = ToINIFil e.ReadStri ng(section , key, '') ;
  1169                  Result  := (val1  <> val2);
  1170                  if Res ult then
  1171                    brea k;
  1172                end;
  1173                if Resul t then
  1174                  break;
  1175              end;
  1176           fi nally
  1177              ToINIFile. free;
  1178           en d;
  1179         fina lly
  1180           Fr omINIFile. free;
  1181         end;
  1182       finall y
  1183         Sect ions.free;
  1184         Valu es.free;
  1185       end;
  1186     end;
  1187  
  1188   {$REGION ' ********** ********** *** Archiv ed Sub Met hods ***** ********** ********'}
  1189   {
  1190     function  IsUseLine (data: str ing): bool ean;
  1191     var
  1192     p: Integ er;
  1193     begin
  1194     Result : = (copy(da ta, 1, 4)  = 'use ');
  1195     if Resul t then
  1196     begin
  1197     Result : = FALSE;
  1198     p := pos ('"', data );
  1199     if p > 0  then
  1200     begin
  1201     p := pos EX('"', da ta, p + 1) ;
  1202     if p = l ength(data ) then
  1203     Result : = TRUE;
  1204     end;
  1205     end;
  1206     end;
  1207  
  1208     function  IsFunctio nLine(data : string):  boolean;
  1209     var
  1210     p1, p2:  Integer;
  1211     line: st ring;
  1212     begin
  1213     Result : = FALSE;
  1214     line :=  data;
  1215     p1 := po s(' ', lin e);
  1216     if (p1 >  0) then
  1217     begin
  1218     if copy( line, 1, p 1 - 1) = ' script' th en
  1219     Result : = TRUE
  1220     else
  1221     begin
  1222     p2 := po sEX(' ', l ine, p1 +  1);
  1223     if p2 >  0 then
  1224     begin
  1225     line :=  copy(line,  p1 + 1, p 2 - p1 - 1 );
  1226     if (line  = 'functi on') then
  1227     Result : = TRUE;
  1228     end;
  1229     end;
  1230     end;
  1231     end;
  1232  
  1233     function  CheckForU seLineAndF unction(Fr omFile, To File: stri ng): boole an;
  1234     var
  1235     FromData : TStringL ist;
  1236     ToData:  TStringLis t;
  1237     UseLine:  string;
  1238     I: Integ er;
  1239     line: st ring;
  1240  
  1241     begin
  1242     Result : = FALSE;
  1243     FromData  := TStrin gList.Crea te;
  1244     ToData : = TStringL ist.Create ;
  1245     try
  1246     UseLine  := '';
  1247     AppUseLi ne := '';
  1248     AppStart FunctionLi ne := -1;
  1249     FromData .LoadFromF ile(FromFi le);
  1250     for I :=  0 to From Data.Count  - 1 do
  1251     begin
  1252     line :=  LowerCase( trim(FromD ata[I]));
  1253     if (UseL ine = '')  and IsUseL ine(line)  then
  1254     begin
  1255     UseLine  := line;
  1256     AppUseLi ne := From Data[I];
  1257     end
  1258     else if  (AppStartF unctionLin e < 0) and  IsFunctio nLine(line ) then
  1259     AppStart FunctionLi ne := I;
  1260     if (UseL ine <> '')  and (AppS tartFuncti onLine >=  0) then
  1261     break;
  1262     end;
  1263     if (UseL ine = '')  or (AppSta rtFunction Line < 0)  then
  1264     exit;
  1265  
  1266     AppNeeds UseLine :=  TRUE;
  1267     AppScrip tNeedsFunc tion := TR UE;
  1268     ToData.L oadFromFil e(ToFile);
  1269     for I :=  0 to ToDa ta.Count -  1 do
  1270     begin
  1271     line :=  LowerCase( trim(ToDat a[I]));
  1272     if AppNe edsUseLine  and IsUse Line(line)  and (line  = UseLine ) then
  1273     AppNeeds UseLine :=  FALSE
  1274     else if  AppScriptN eedsFuncti on and IsF unctionLin e(line) th en
  1275     AppScrip tNeedsFunc tion := FA LSE;
  1276     if (not  AppNeedsUs eLine) and  (not AppS criptNeeds Function)  then
  1277     break;
  1278     end;
  1279     if AppNe edsUseLine  or AppScr iptNeedsFu nction the n
  1280     Result : = TRUE;
  1281     finally
  1282     FromData .Free;
  1283     ToData.F ree;
  1284     end;
  1285     end;
  1286  
  1287     function  DoScriptM erge(FromF ile, ToFil e, ThisCom piler: str ing): bool ean;
  1288     var
  1289     BackupFi le: string ;
  1290     FromData : TStringL ist;
  1291     ToData:  TStringLis t;
  1292     I, idx:  Integer;
  1293     ExitCode : Integer;
  1294     begin
  1295     Result : = TRUE;
  1296     BackupFi le := ToFi le + '.BAC KUP';
  1297     if FileE xists(Back upFile) th en
  1298     begin
  1299     MakeFile Writable(B ackupFile) ;
  1300     DeleteFi le(PChar(B ackupFile) );
  1301     end;
  1302     DeleteCo mpiledFile (ToFile);
  1303     CopyFile (PChar(ToF ile), PCha r(BackupFi le), FALSE );
  1304     MakeFile Writable(T oFile);
  1305     FromData  := TStrin gList.Crea te;
  1306     ToData : = TStringL ist.Create ;
  1307     try
  1308     ToData.L oadFromFil e(ToFile);
  1309     if AppNe edsUseLine  then
  1310     ToData.I nsert(0, A ppUseLine) ;
  1311     if AppSc riptNeedsF unction th en
  1312     begin
  1313     FromData .LoadFromF ile(FromFi le);
  1314     ToData.I nsert(1, ' ');
  1315     idx := 2 ;
  1316     for I :=  AppStartF unctionLin e to FromD ata.Count  - 1 do
  1317     begin
  1318     ToData.I nsert(idx,  FromData[ I]);
  1319     inc(idx) ;
  1320     end;
  1321     ToData.I nsert(idx,  '');
  1322     end;
  1323     if not a ssigned(JA WSAPI) the n
  1324     JAWSAPI  := CoJawsA pi.Create;
  1325     ToData.S aveToFile( ToFile);
  1326     ExitCode  := Execut eAndWait(' "' + ThisC ompiler +  '"', '"' +  ToFile +  '"');
  1327     JAWSAPI. StopSpeech ;
  1328     if ExitC ode = 0 th en // comp ile succee ded!
  1329     ReloadCo nfiguratio n
  1330     else
  1331     Result : = FALSE; / / compile  failed - j ust copy t he new one
  1332     finally
  1333     FromData .Free;
  1334     ToData.F ree;
  1335     end;
  1336     end;
  1337  
  1338   }
  1339   {$ENDREGIO N}
  1340   // ******* ********** ********** ********** ********** ********** *********
  1341   // Fire of f the corr ect check  based on t he Compare Type
  1342   // ******* ********** ********** ********** ********** ********** *********
  1343     function  UpdateNee ded(FromFi le, ToFile : string;
  1344       Compar eType: TCo mpareType) : Boolean;
  1345     begin
  1346       Result  := TRUE;
  1347       try
  1348         case  CompareTy pe of
  1349           jc ScriptMerg e:
  1350              Result :=  VersionDif ferent(Fro mFile, ToF ile);
  1351           jc Prior:
  1352              Result :=  LastFileUp dated;
  1353           jc Version:
  1354              Result :=  VersionDif ferent(Fro mFile, ToF ile);
  1355           jc INI:
  1356              Result :=  INIUpdateN eeded(From File, ToFi le);
  1357           jc LineItems:
  1358              Result :=  LineItemUp dateNeeded (FromFile,  ToFile);
  1359           jc INIMRG:
  1360              Result :=  INIUpdateN eeded(From File, ToFi le);
  1361           jc LineItemsM RG:
  1362              Result :=  LineItemUp dateNeeded (FromFile,  ToFile);
  1363         end;
  1364       except
  1365         on E : Exceptio n do
  1366           FJ AWSFileErr or := E.Me ssage;
  1367       end;
  1368     end;
  1369  
  1370   // ******* ********** ********** ********** ********** ********** *********
  1371   // Update  the Ini Fi le
  1372   // ******* ********** ********** ********** ********** ********** *********
  1373     procedur e INIFileU pdate(From File, ToFi le: String );
  1374     var
  1375       FromIN IFile, ToI NIFile: TI NIFile;
  1376       Sectio ns, Values : TStringL ist;
  1377       i, j:  Integer;
  1378       sectio n, key, va l1, val2:  string;
  1379       modifi ed: Boolea n;
  1380     begin
  1381       modifi ed := FALS E;
  1382       Sectio ns := TStr ingList.Cr eate;
  1383       Values  := TStrin gList.Crea te;
  1384       try
  1385         From INIFile :=  TINIFile. Create(Fro mFile);
  1386         try
  1387           To INIFile :=  TINIFile. Create(ToF ile);
  1388           tr y
  1389              FromINIFil e.ReadSect ions(Secti ons);
  1390              for i := 0  to Sectio ns.Count -  1 do
  1391              begin
  1392                section  := Section s[i];
  1393                FromINIF ile.ReadSe ctionValue s(section,  Values);
  1394                for j :=  0 to Valu es.Count -  1 do
  1395                begin
  1396                  key :=  Values.Na mes[j];
  1397                  val1 : = Values.V alueFromIn dex[j];
  1398                  val2 : = ToINIFil e.ReadStri ng(section , key, '') ;
  1399                  if (va l1 <> val2 ) then
  1400                  begin
  1401                    ToIN IFile.Writ eString(se ction, key , val1);
  1402                    modi fied := TR UE;
  1403                  end;
  1404                end;
  1405              end;
  1406           fi nally
  1407              if modifie d then
  1408                ToINIFil e.UpdateFi le();
  1409              ToINIFile. free;
  1410           en d;
  1411         fina lly
  1412           Fr omINIFile. free;
  1413         end;
  1414       finall y
  1415         Sect ions.free;
  1416         Valu es.free;
  1417       end;
  1418     end;
  1419  
  1420   // ******* ********** ********** ********** ********** ********** *********
  1421   // Update  the Line I tem
  1422   // ******* ********** ********** ********** ********** ********** *********
  1423     procedur e LineItem FileUpdate (FromFile,  ToFile: s tring);
  1424     var
  1425       fromLi st, toList : TStringL ist;
  1426       i, idx : Integer;
  1427       line:  string;
  1428       modifi ed: Boolea n;
  1429     begin
  1430       modifi ed := FALS E;
  1431       fromLi st := TStr ingList.Cr eate;
  1432       toList  := TStrin gList.Crea te;
  1433       try
  1434         from List.LoadF romFile(Fr omFile);
  1435         toLi st.LoadFro mFile(ToFi le);
  1436         for  i := 0 to  fromList.C ount - 1 d o
  1437         begi n
  1438           li ne := from List[i];
  1439           if  Trim(line ) <> '' th en
  1440           be gin
  1441              idx := toL ist.IndexO f(line);
  1442              if idx < 0  then
  1443              begin
  1444                toList.A dd(line);
  1445                modified  := TRUE;
  1446              end;
  1447           en d;
  1448         end;
  1449       finall y
  1450         if m odified th en
  1451           to List.SaveT oFile(ToFi le);
  1452         toLi st.free;
  1453         from List.free;
  1454       end;
  1455     end;
  1456  
  1457   // ******* ********** ********** ********** ********** ********** *********
  1458   // Remove  a Compiled  file
  1459   // ******* ********** ********** ********** ********** ********** *********
  1460     procedur e DeleteCo mpiledFile (ToFile: s tring);
  1461     var
  1462       Compil edFile: st ring;
  1463     begin
  1464       Compil edFile :=  Copy(ToFil e, 1, Leng th(ToFile)  -
  1465         Leng th(Extract FileExt(To File)));
  1466       Compil edFile :=  CompiledFi le + Compi ledScriptF ileExtensi on;
  1467       if Fil eExists(Co mpiledFile ) then
  1468       begin
  1469         Make FileWritab le(Compile dFile);
  1470         Dele teFile(PCh ar(Compile dFile));
  1471       end;
  1472     end;
  1473  
  1474     Procedur e LoadFile IntoCompil er(ToFile:  string; T hisJawsRec : TJawsRec ord);
  1475     var
  1476       FileNa me, extNam e, Depfile : String;
  1477       X, Y:  Integer;
  1478       LookFo rVaApp: Bo olean;
  1479     begin
  1480       SetLen gth(Compil eFiles, Le ngth(Compi leFiles) +  1);
  1481       Compil eFiles[Hig h(CompileF iles)].Fil eName := T oFile;
  1482       Compil eFiles[Hig h(CompileF iles)].Com piled := F ALSE;
  1483       Compil eFiles[Hig h(CompileF iles)].Com piler := T hisJawsRec .Compiler;
  1484  
  1485       // Loa d dependen cies
  1486       FileNa me := Piec e(ExtractF ileName(To File), '.' , 1);
  1487       extNam e := Piece (ExtractFi leName(ToF ile), '.',  2);
  1488       LookFo rVaApp :=  FileName =  Piece(Ext ractFileNa me(ParamSt r(0)), '.' , 1);
  1489  
  1490       // Bui ld depende ncies
  1491       for X  := Low(Scr iptFiles)  to High(Sc riptFiles)  do
  1492       begin
  1493         if ( ExtractFil eName(Scri ptFiles[X] .FileName)  = Extract FileName(T oFile)) or
  1494           (( LookForVaA pp) and
  1495           (U pperCase(P iece(Extra ctFileName (ScriptFil es[X].File Name), '.' , 1))
  1496           =  UpperCase( JAWS_APP_N AME)) and
  1497           (U pperCase(P iece(Extra ctFileName (ScriptFil es[X].File Name), '.' , 2))
  1498           =  UpperCase( extName)))  then
  1499         begi n
  1500           if  Length(Sc riptFiles[ X].Depende ncies) > 0  then
  1501           be gin
  1502              for Y := L ow(ScriptF iles[X].De pendencies )
  1503                to High( ScriptFile s[X].Depen dencies) d o
  1504              begin
  1505                SetLengt h(CompileF iles[High( CompileFil es)].Depen dentFile,
  1506                  Length (CompileFi les[High(C ompileFile s)].Depend entFile) +  1);
  1507                Depfile  := Extract FilePath(T oFile);
  1508                Depfile  := AppendB ackSlash(D epfile);
  1509                CompileF iles[High( CompileFil es)].Depen dentFile
  1510                  [High( CompileFil es[High(Co mpileFiles )].Depende ntFile)].F ileName :=
  1511                  Depfil e + Script Files[X].D ependencie s[Y].FileN ame;
  1512                CompileF iles[High( CompileFil es)].Depen dentFile
  1513                  [High( CompileFil es[High(Co mpileFiles )].Depende ntFile)
  1514                  ].Comp iled := FA LSE;
  1515                CompileF iles[High( CompileFil es)].Depen dentFile
  1516                  [High( CompileFil es[High(Co mpileFiles )].Depende ntFile)].C ompiler :=
  1517                  ThisJa wsRec.Comp iler;
  1518              end;
  1519           en d;
  1520           br eak;
  1521         end;
  1522       end;
  1523     end;
  1524  
  1525   // ******* ********** ********** ********** ********** ********** *********
  1526   // Update  the ToFile  from the  FromFile
  1527   // ******* ********** ********** ********** ********** ********** *********
  1528     procedur e UpdateFi le(FromFil e, ToFile:  string; T hisJawsRec : TJawsRec ord;
  1529       info:  TFileInfo) ;
  1530     var
  1531       DoCopy : Boolean;
  1532       error:  Boolean;
  1533       CheckO verwrite:  Boolean;
  1534       Versio nNum: stri ng;
  1535     begin
  1536       DoCopy  := FALSE;
  1537       if Fil eExists(To File) then
  1538       begin
  1539         Make FileWritab le(ToFile) ;
  1540         Chec kOverwrite  := TRUE;
  1541  
  1542         Vers ionNum :=  FloatToStr (ThisJawsR ec.Version );
  1543         if P os('.', Ve rsionNum)  > 0 then
  1544           Ve rsionNum : = Copy(Ver sionNum, 1 , Pos('.',  VersionNu m) - 1);
  1545         if F indCommand Switch('FO RCEUPD') o r
  1546           Fi ndCommandS witch('FOR CEUPD' + V ersionNum)  then
  1547         begi n
  1548           Ch eckOverwri te := FALS E;
  1549           Do Copy := TR UE;
  1550         end
  1551         else
  1552         begi n
  1553  
  1554           tr y
  1555              case info. CompareTyp e of
  1556                jcScript Merge:
  1557                  DoCopy  := TRUE;
  1558                jcPrior,  jcVersion :
  1559                  DoCopy  := TRUE;
  1560                jcINI:
  1561                  INIFil eUpdate(Fr omFile, To File);
  1562                jcLineIt ems:
  1563                  LineIt emFileUpda te(FromFil e, ToFile) ;
  1564                jcINIMRG :
  1565                  INIFil eUpdate(Fr omFile, To File);
  1566                jcLineIt emsMRG:
  1567                  LineIt emFileUpda te(FromFil e, ToFile) ;
  1568              end;
  1569           ex cept
  1570              on E: Exce ption do
  1571                FJAWSFil eError :=  E.Message;
  1572           en d;
  1573         end;
  1574       end
  1575       else
  1576       begin
  1577         Chec kOverwrite  := FALSE;
  1578         DoCo py := TRUE ;
  1579       end;
  1580  
  1581       if DoC opy then
  1582       begin
  1583         erro r := FALSE ;
  1584         if n ot CopyFil e(PChar(Fr omFile), P Char(ToFil e), FALSE)  then
  1585         begi n
  1586           er ror := TRU E;
  1587           Lo gTxt := Lo gTxt + #13 #10 + 'Err or copying  to: "' +
  1588              ExtractFil ePath(ToFi le) + '" '  + CRLF +
  1589              '!! Error  in CopyFil e method!! ';
  1590           if  assigned( UserSplash ) then
  1591              UserSplash .TaskError  := 'Error  copying t o: "' +
  1592                ExtractF ilePath(To File);
  1593         end
  1594         else
  1595           Lo gTxt := Lo gTxt + #13 #10 + 'cop ied to: "'  +
  1596              ExtractFil ePath(ToFi le) + '".' ;
  1597  
  1598         if ( not error)  and (not  FileExists (ToFile))  then
  1599         begi n
  1600           er ror := TRU E;
  1601         end;
  1602         if ( not error)  and Check Overwrite  and (info. CompareTyp e <> jcPri or) and
  1603           Up dateNeeded (FromFile,  ToFile, i nfo.Compar eType) the n
  1604           er ror := TRU E;
  1605         if e rror and ( not FileEr rorExists)  then
  1606           FJ AWSFileErr or := 'Err or copying  "' + Extr actFilePat h(FromFile ) + '" to'
  1607              + CRLF + ' "' + Extra ctFilePath (ToFile) +  '".';
  1608         if ( not error)  and (info .Compile)  then
  1609         begi n
  1610           De leteCompil edFile(ToF ile);
  1611           Lo adFileInto Compiler(T oFile, Thi sJawsRec);
  1612           Lo gTxt := Lo gTxt + #13 #10 + 'Com pile Neede d: YES';
  1613         end
  1614         else
  1615           Lo gTxt := Lo gTxt + #13 #10 + 'Com pile Neede d: NO';
  1616       end;
  1617     end;
  1618  
  1619     Procedur e UpdateUs es(ToFile,  aUpdateSt r: string) ;
  1620     var
  1621       tempSt rLst: TStr ingList;
  1622       i: Int eger;
  1623     begin
  1624       tempSt rLst := TS tringList. Create;
  1625       try
  1626         temp StrLst.Loa dFromFile( ToFile);
  1627         for  i := 0 to  tempStrLst .Count - 1  do
  1628         begi n
  1629           if  Pos(JAWS_ FRAMEWORK_ USES, temp StrLst[i])  > 0 then
  1630           be gin
  1631              tempStrLst [i] := aUp dateStr;
  1632              break;
  1633           en d;
  1634         end;
  1635         temp StrLst.Sav eToFile(To File);
  1636       finall y
  1637         temp StrLst.fre e;
  1638       end;
  1639     end;
  1640  
  1641   // ******* ********** ********** ********** ********** ********** *********
  1642   // Keeps J aws files  aliged wit h the ones  in Vist\C ommon File s
  1643   // ******* ********** ********** ********** ********** ********** *********
  1644     procedur e EnsureJA WSScriptsA reUpToDate (var ThisJ awsRec: TJ awsRecord) ;
  1645     var
  1646       DestFi le, FromFi le, ToFile , AppName,  Ext: stri ng;
  1647       idx1,  idx2, i, X : Integer;
  1648       DoUpda te, DoUses : Boolean;
  1649       Versio nNum, Uses Str, UpdFi leName: St ring;
  1650     begin
  1651       AppNam e := Extra ctFileName (ParamStr( 0));
  1652       Ext :=  ExtractFi leExt(AppN ame);
  1653       AppNam e := LeftS tr(AppName , Length(A ppName) -  Length(Ext ));
  1654       DestPa th := '';
  1655       idx1 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, This JawsRec.Us erScriptDi r);
  1656       idx2 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, This JawsRec.De faultScrip tDir);
  1657       if (id x1 > 0) an d (idx2 >  0) then
  1658       begin
  1659         Dest Path := Co py(ThisJaw sRec.UserS criptDir,  1, idx1 -  1) +
  1660           Co py(ThisJaw sRec.Defau ltScriptDi r, idx2, M axInt);
  1661  
  1662         Dest File := De stPath + A ppName;
  1663         This JawsRec.FD ictionaryF ileName :=  DestFile  + Dictiona ryFileExte nsion;
  1664         This JawsRec.FC onfigFile  := DestFil e + Config FileExtens ion;
  1665         This JawsRec.FK eyMapFile  := DestFil e + KeyMap Extension;
  1666         Last FileUpdate d := FALSE ;
  1667  
  1668         // L ook up the  files
  1669         if L ength(Scri ptFiles) =  0 then
  1670           Ge tScriptFil es(ScriptF iles);
  1671  
  1672         for  i := low(S criptFiles ) to high( ScriptFile s) do
  1673         begi n
  1674           Do Uses := FA LSE;
  1675           //  Look for  dependenci es
  1676           if  Length(Sc riptFiles[ i].Depende ncies) > 0  then
  1677           be gin
  1678              UsesStr :=  '';
  1679              // add the  compiled  dependenci es to the  uses
  1680              for X := L ow(ScriptF iles[i].De pendencies )
  1681                to High( ScriptFile s[i].Depen dencies) d o
  1682              begin
  1683                UpdFileN ame := Pie ce(ScriptF iles[i].De pendencies [X].FileNa me, '.',
  1684                  1) + C ompiledScr iptFileExt ension;
  1685                UsesStr  := UsesStr  + 'use "'  + UpdFile Name + '"'  + #10#13
  1686              end;
  1687              DoUses :=  TRUE;
  1688           en d;
  1689  
  1690           if  UpperCase (Piece(Ext ractFileNa me(ScriptF iles[i].Fi leName), ' .', 1)) =  JAWS_APP_N AME
  1691           th en
  1692           be gin
  1693              FromFile : = ScriptFi les[i].Fil eName;
  1694              ToFile :=  DestFile +  ExtractFi leExt(Scri ptFiles[i] .FileName) ;
  1695           en d
  1696           el se
  1697           be gin
  1698              FromFile : = ScriptFi les[i].Fil eName;
  1699              ToFile :=  DestPath +  ExtractFi leName(Scr iptFiles[i ].FileName );
  1700           en d;
  1701           Lo gTxt := 'F ilename: '  + Extract FileName(F romFile);
  1702           if  ScriptFil es[i].Exis t then
  1703           be gin
  1704              if FileExi sts(ToFile ) then
  1705              begin
  1706                // add f orce for r ebuild
  1707                VersionN um := Floa tToStr(Thi sJawsRec.V ersion);
  1708                if Pos(' .', Versio nNum) > 0  then
  1709                  Versio nNum := Co py(Version Num, 1, Po s('.', Ver sionNum) -  1);
  1710  
  1711                if FindC ommandSwit ch('FORCEU PD') then
  1712                  DoUpda te := TRUE
  1713                else if  FindComman dSwitch('F ORCEUPD' +  VersionNu m) then
  1714                  DoUpda te := TRUE
  1715                else
  1716                  DoUpda te := Upda teNeeded(F romFile, T oFile,
  1717                    Scri ptFiles[i] .CompareTy pe);
  1718                if DoUpd ate then
  1719                begin
  1720                  MakeFi leWritable (ToFile);
  1721                  LogTxt  := LogTxt  + #13#10  + 'Update  needed: YE S'
  1722                end
  1723                else
  1724                  LogTxt  := LogTxt  + #13#10  + 'Update  needed: NO ';
  1725  
  1726              end
  1727              else
  1728                DoUpdate  := TRUE;
  1729              LastFileUp dated := D oUpdate;
  1730              if DoUpdat e and (not  FileError Exists) th en
  1731              begin
  1732                UpdateFi le(FromFil e, ToFile,  ThisJawsR ec, Script Files[i]);
  1733                if DoUse s then
  1734                  Update Uses(ToFil e, UsesStr );
  1735                ScriptFi leChanges  := TRUE;
  1736              end;
  1737  
  1738              if FileErr orExists t hen
  1739                break;
  1740              LogInterfa ce.LogText (' Compare   ', LogTx t);
  1741           en d;
  1742           Us erSplash.I ncProg;
  1743         end;
  1744  
  1745       end
  1746       else
  1747         FJAW SFileError  := 'Unkno wn File Er ror';
  1748       // sho uld never  happen - c ondition c hecked pre viously
  1749     end;
  1750  
  1751   // ******* ********** ********** ********** ********** ********** *********
  1752   // Recompi le Jaws wi th the new  files
  1753   // ******* ********** ********** ********** ********** ********** *********
  1754     procedur e DoCompil es(ThisJaw sRec: TJaw sRecord);
  1755     var
  1756       i, X,  Y: Integer ;
  1757       RunTxt : String;
  1758       RunSta tus: Boole an;
  1759     begin
  1760       if not  assigned( JAWSAPI) t hen
  1761         JAWS API := CoJ awsApi.Cre ate;
  1762  
  1763       LogInt erface.Log Text(' Com pile  ', ' Compiler:  ' + ThisJa wsRec.Comp iler);
  1764       for i  := Low(Com pileFiles)  to High(C ompileFile s) do
  1765       begin
  1766         if n ot Compile Files[i].C ompiled th en
  1767         begi n
  1768           if  Length(Co mpileFiles [i].Depend entFile) >  0 then
  1769           be gin
  1770              for X := L ow(Compile Files[i].D ependentFi le)
  1771                to High( CompileFil es[i].Depe ndentFile)  do
  1772              begin
  1773                if not C ompileFile s[i].Depen dentFile[X ].Compiled  then
  1774                begin
  1775                  try
  1776                    RunS tatus := C ompileFile s[i].Depen dentFile[X ]
  1777                      .C ompileFile (RunTxt);
  1778                    if n ot RunStat us then
  1779                    begi n
  1780                      Lo gInterface .LogText('  ERROR  ',
  1781                         'File: ' +  ExtractFi leName(Com pileFiles[ i].Depende ntFile[X]
  1782                         .FileName)  + #13#10  + RunTxt);
  1783                      if  assigned( UserSplash ) then
  1784                         UserSplash .TaskError  := 'File:  ' +
  1785                           ExtractF ileName(Co mpileFiles [i].Depend entFile[X] .FileName)
  1786                           + ' - '  + RunTxt;
  1787                    end
  1788                    else
  1789                      Lo gInterface .LogText('  Compile   ',
  1790                         'File: ' +  ExtractFi leName(Com pileFiles[ i].Depende ntFile[X]
  1791                         .FileName)  + #13#10  + RunTxt);
  1792  
  1793                    JAWS API.StopSp eech;
  1794                    // U pdate the  record
  1795                    Comp ileFiles[i ].Dependen tFile[X].C ompiled :=  TRUE;
  1796  
  1797                    // F ind the ma in record  and mark i t as compi led
  1798                    for  Y := Low(C ompileFile s) to High (CompileFi les) do
  1799                    begi n
  1800                      if  ExtractFi leName(Com pileFiles[ Y].FileNam e)
  1801                         = ExtractF ileName(Co mpileFiles [i].Depend entFile[X] .FileName)
  1802                      th en
  1803                      be gin
  1804                         CompileFil es[Y].Comp iled := TR UE;
  1805                         break;
  1806                      en d;
  1807                    end;
  1808  
  1809                  except
  1810                    on E : Exceptio n do
  1811                    begi n
  1812                      Lo gInterface .LogText(' Error comp iling ' +
  1813                         ExtractFil eName(Comp ileFiles[i ].Dependen tFile[X].F ileName),
  1814                         E.Message) ;
  1815                      if  assigned( UserSplash ) then
  1816                         UserSplash .TaskError  := 'Error  compiling  ' +
  1817                           ExtractF ileName(Co mpileFiles [i].Depend entFile[X] .FileName)
  1818                           + ' - '  + E.Messag e;
  1819                    end;
  1820                  end;
  1821                end;
  1822              end;
  1823           en d;
  1824  
  1825           tr y
  1826              RunStatus  := Compile Files[i].C ompileFile (RunTxt);
  1827              if not Run Status the n
  1828              begin
  1829                LogInter face.LogTe xt(' ERROR   ',
  1830                  'File:  ' + Extra ctFileName (CompileFi les[i].Fil eName) + # 13#10
  1831                  + RunT xt);
  1832                if assig ned(UserSp lash) then
  1833                  UserSp lash.TaskE rror := 'F ile: ' +
  1834                    Extr actFileNam e(CompileF iles[i].Fi leName) +  ' - ' + Ru nTxt;
  1835              end
  1836              else
  1837                LogInter face.LogTe xt(' Compi le  ',
  1838                  'File:  ' + Extra ctFileName (CompileFi les[i].Fil eName) + # 13#10
  1839                  + RunT xt);
  1840              JAWSAPI.St opSpeech;
  1841              // Update  the record
  1842              CompileFil es[i].Comp iled := TR UE;
  1843           ex cept
  1844              on E: Exce ption do
  1845              begin
  1846                LogInter face.LogTe xt('Error  compiling  ' +
  1847                  Extrac tFileName( CompileFil es[i].File Name), E.M essage);
  1848                if assig ned(UserSp lash) then
  1849                  UserSp lash.TaskE rror := 'E rror compi ling ' +
  1850                    Extr actFileNam e(CompileF iles[i].Fi leName) +  ' - ' + E. Message;
  1851              end;
  1852           en d;
  1853  
  1854         end;
  1855       end;
  1856  
  1857       Reload Configurat ion;
  1858     end;
  1859  
  1860   begin
  1861     Result : = FALSE;
  1862     for Arry Cnt := Low (JawsRecor d) to High (JawsRecor d) do
  1863     begin
  1864       StatTe xt := 'Pro cessing JA WS ' + Flo atToStr(Ja wsRecord[A rryCnt].Ve rsion);
  1865       LogInt erface.Log Text('JAWS  ' + Float ToStr(Jaws Record[Arr yCnt].Vers ion), '');
  1866       UserSp lash.TaskT itle := St atText;
  1867       Script FileChange s := FALSE ;
  1868       if JAW SManager.R equiredFil esFound th en
  1869       begin
  1870         FJAW SFileError  := '';
  1871         SetL ength(Comp ileFiles,  0);
  1872         try
  1873           Us erSplash.T askText :=
  1874              'Ensuring  Jaws scrip t files ar e up to da te with la test versi ons';
  1875           En sureJAWSSc riptsAreUp ToDate(Jaw sRecord[Ar ryCnt]);
  1876           Us erSplash.I ncProg;
  1877  
  1878           if  Length(Co mpileFiles ) > 0 then
  1879           be gin
  1880              UserSplash .TaskText  :=
  1881                'Jaws sc ripts upda ted. Compi ling neces sary scrip t files';
  1882              DoCompiles (JawsRecor d[ArryCnt] );
  1883           en d;
  1884           Us erSplash.I ncProg;
  1885         fina lly
  1886           Se tLength(Co mpileFiles , 0);
  1887         end;
  1888         if F ileErrorEx ists then
  1889           Sh owError(JA WS_ERROR_F ILE_IO, [F JAWSFileEr ror]);
  1890       end
  1891       else
  1892         User Splash.Inc Prog(2 + L ength(Scri ptFiles));
  1893       UserSp lash.IncPr og;
  1894     end;
  1895     UserSpla sh.TaskTit le := 'Gen eral';
  1896     UserSpla sh.TaskTex t := 'Veri fying User  compatibi lity';
  1897     UserSpla sh.IncProg ;
  1898     fCompone ntCallBack Proc := Co mponentCal lBackProc;
  1899     fScriptF ilesChange d := Scrip tFileChang es;
  1900     Result : = JAWSTalk ing2Curren tUser;
  1901  
  1902   end;
  1903  
  1904   // ******* ********** ********** ********** ********** ********** *********
  1905   // Returns  if the Ja wsManager  is running
  1906   // ******* ********** ********** ********** ********** ********** *********
  1907   class func tion TJAWS Manager.Is Running(Hi ghVersion,  LowVersio n: Word):  BOOL;
  1908  
  1909     function  Component VersionSup ported: Bo olean;
  1910     var
  1911       Suppor tedHighVer sion, Supp ortedLowVe rsion: Int eger;
  1912       FileNa me, newVer sion, conv ertedVersi on, curren tVersion:  string;
  1913       addr:  Pointer;
  1914  
  1915     begin
  1916       addr : = @TJAWSMa nager.IsRu nning;
  1917       FileNa me := GetD LLFileName (addr);
  1918       curren tVersion : = FileVers ionValue(F ileName, F ILE_VER_FI LEVERSION) ;
  1919       Versio nStringSpl it(current Version, S upportedHi ghVersion,
  1920         Supp ortedLowVe rsion);
  1921       Result  := FALSE;
  1922       if (Hi ghVersion  < Supporte dHighVersi on) then
  1923         Resu lt := TRUE
  1924       else i f (HighVer sion = Sup portedHigh Version) a nd
  1925         (Low Version <=  Supported LowVersion ) then
  1926         Resu lt := TRUE ;
  1927       if not  Result th en
  1928       begin
  1929         newV ersion :=  IntToStr(H ighVersion ) + '.' +  IntToStr(L owVersion) ;
  1930         conv ertedVersi on := IntT oStr(Suppo rtedHighVe rsion) + ' .' +
  1931           In tToStr(Sup portedLowV ersion);
  1932         Show Error(DLL_ ERROR_VERS ION, [newV ersion, co nvertedVer sion]);
  1933       end;
  1934  
  1935       if Res ult then
  1936         LogI nterface.L ogText('Ja ws Check',  'DLL Vers ion: ' + c urrentVers ion +
  1937           '  supported' )
  1938       else
  1939         LogI nterface.L ogText('Ja ws Check',  'DLL Vers ion: ' + c urrentVers ion +
  1940           '  not suppor ted');
  1941     end;
  1942  
  1943   begin
  1944     Result : = (GetJAWS Window <>  0);
  1945     if Resul t then
  1946       Result  := Compon entVersion Supported;
  1947     if Resul t then
  1948       Result  := JAWSVe rsionOK;
  1949     if Resul t then
  1950     begin
  1951       Ensure Manager;
  1952       with J AWSManager  do
  1953         Resu lt := Requ iredFilesF ound;
  1954     end;
  1955   end;
  1956  
  1957   // ******* ********** ********** ********** ********** ********** *********
  1958   // Verfiy  jaws and a pplication  are ran b y the same  user
  1959   // ******* ********** ********** ********** ********** ********** *********
  1960   class func tion TJAWS Manager.JA WSTalking2 CurrentUse r: Boolean ;
  1961   var
  1962     CurrentU serPath: s tring;
  1963     WhatJAWS Thinks: st ring;
  1964  
  1965     // ***** ********** ********** ********** ********** ********** ********** *
  1966     // Gathe rs the use rname that  ran the p rocess
  1967     // ***** ********** ********** ********** ********** ********** ********** *
  1968     Function  GetProces sDomainAnd User(PID:  DWORD): st ring;
  1969     type
  1970       PUserT oken = ^Us erToken;
  1971  
  1972       _UserT oken = rec ord
  1973         User : TSIDAndA ttributes;
  1974       end;
  1975  
  1976       UserTo ken = _Use rToken;
  1977     var
  1978       TkHand le, PHandl e: THandle ;
  1979       SidUsr : SID_NAME _USE;
  1980       RBuf:  Cardinal;
  1981       PUser:  PUserToke n;
  1982       Domain Size, User Size: DWOR D;
  1983       Ok: Bo olean;
  1984       User,  Domain: st ring;
  1985     begin
  1986       Result  := '';
  1987       PHandl e := OpenP rocess(PRO CESS_QUERY _INFORMATI ON, FALSE,  PID);
  1988       if PHa ndle <> 0  then
  1989       begin
  1990         if O penProcess Token(PHan dle, TOKEN _QUERY, Tk Handle) th en
  1991         begi n
  1992           Ok  := GetTok enInformat ion(TkHand le, TokenU ser, nil,  0, RBuf);
  1993           PU ser := nil ;
  1994           wh ile (not O k) and (Ge tLastError  = ERROR_I NSUFFICIEN T_BUFFER)  do
  1995           be gin
  1996              ReallocMem (PUser, RB uf);
  1997              Ok := GetT okenInform ation(TkHa ndle, Toke nUser, PUs er, RBuf,  RBuf);
  1998           en d;
  1999           Cl oseHandle( TkHandle);
  2000  
  2001           if  not Ok th en
  2002           be gin
  2003              Exit;
  2004           en d;
  2005  
  2006           Us erSize :=  0;
  2007           Do mainSize : = 0;
  2008           Lo okupAccoun tSid(nil,  PUser.User .Sid, nil,  UserSize,  nil,
  2009              DomainSize , SidUsr);
  2010           if  (UserSize  <> 0) and  (DomainSi ze <> 0) t hen
  2011           be gin
  2012              SetLength( User, User Size);
  2013              SetLength( Domain, Do mainSize);
  2014              if LookupA ccountSid( nil, PUser .User.Sid,  PChar(Use r), UserSi ze,
  2015                PChar(Do main), Dom ainSize, S idUsr) the n
  2016                Result : = StrPas(P Char(Domai n)) + '/'  + StrPas(P Char(User) );
  2017           en d;
  2018  
  2019           if  Ok then
  2020           be gin
  2021              FreeMem(PU ser);
  2022           en d;
  2023         end;
  2024         Clos eHandle(PH andle);
  2025       end;
  2026     end;
  2027  
  2028   {$REGION ' ********** ********** *** Archiv ed Sub Met hod ****** ********** *******'}
  2029   {
  2030     procedur e Fix(var  path: stri ng);
  2031     var
  2032     idx: Int eger;
  2033     begin
  2034     idx := p os(APP_DAT A, LowerCa se(path));
  2035     if idx >  0 then
  2036     path :=  LeftStr(pa th, idx -  1);
  2037     idx := l ength(path );
  2038     while (i dx > 0) an d (path[id x] <> '\')  do
  2039     dec(idx) ;
  2040     delete(p ath, 1, id x);
  2041     end;
  2042   }
  2043   {$ENDREGIO N}
  2044   // ******* ********** ********** ********** ********** ********** *********
  2045   // Verify  same user  using Jaws  and Appli cation
  2046   // ******* ********** ********** ********** ********** ********** *********
  2047     function  UserProbl emExists:  Boolean;
  2048     var
  2049       JAWSWi ndow: HWND ;
  2050       pPid:  DWORD;
  2051     begin
  2052       JAWSWi ndow := Ge tJAWSWindo w;
  2053       pPid : = INVALID_ HANDLE_VAL UE;
  2054       GetWin dowThreadP rocessID(J AWSWindow,  @pPid);
  2055       Curren tUserPath  := GetProc essDomainA ndUser(Get CurrentPro cessID);
  2056       WhatJA WSThinks : = GetProce ssDomainAn dUser(pPid );
  2057       Result  := (Lower Case(Curre ntUserPath ) <> Lower Case(WhatJ AWSThinks) );
  2058     end;
  2059  
  2060   begin
  2061     if UserP roblemExis ts then
  2062     begin
  2063       ShowEr ror(JAWS_E RROR_USER_ PROBLEM);
  2064       Result  := FALSE;
  2065     end
  2066     else
  2067       Result  := TRUE;
  2068   end;
  2069  
  2070   // ******* ********** ********** ********** ********** ********** *********
  2071   // Verify  the versio n of Jaws  is support ed
  2072   // ******* ********** ********** ********** ********** ********** *********
  2073   class func tion TJAWS Manager.JA WSVersionO K: Boolean ;
  2074   var
  2075     JFileVer sion: stri ng;
  2076     JFile: s tring;
  2077     i: Integ er;
  2078     ErrFound , Ok: Bool ean;
  2079  
  2080     // ***** ********** ********** ********** ********** ********** ********** *
  2081     // Try t o create t he Jaws Ap i
  2082     // ***** ********** ********** ********** ********** ********** ********** *
  2083     function  OlderVers ionOKIfCOM ObjectInst alled: Boo lean;
  2084     var
  2085       api: I JawsApi;
  2086     begin
  2087       Result  := Versio nOK(JAWS_R EQUIRED_VE RSION, JFi leVersion) ;
  2088       if Res ult then
  2089       begin
  2090         try
  2091           tr y
  2092              api := CoJ awsApi.Cre ate;
  2093           ex cept
  2094              Result :=  FALSE;
  2095           en d;
  2096         fina lly
  2097           ap i := nil;
  2098         end;
  2099       end;
  2100     end;
  2101  
  2102   begin
  2103     ErrFound  := FALSE;
  2104     for i :=  Low(JawsR ecord) to  High(JawsR ecord) do
  2105     begin
  2106       JFile  := Extract FilePath(J awsRecord[ i].Compile r) +
  2107         JAWS _APPLICATI ON_FILENAM E;
  2108       if Fil eExists(JF ile) then
  2109       begin
  2110         JFil eVersion : = FileVers ionValue(J File, FILE _VER_FILEV ERSION);
  2111         Ok : = VersionO K(JAWS_COM _OBJECT_VE RSION, JFi leVersion) ;
  2112         if n ot Ok then
  2113           Ok  := OlderV ersionOKIf COMObjectI nstalled;
  2114       end
  2115       else
  2116       begin
  2117         // i f file not  found, th en assume  a future v ersion whe re the exe  was moved
  2118         // t o a differ ent locati on
  2119         Ok : = TRUE;
  2120       end;
  2121       if not  Ok then
  2122       begin
  2123         ErrF ound := TR UE;
  2124         brea k;
  2125       end;
  2126       if Ok  then
  2127         LogI nterface.L ogText('Ja ws Check',  'Instance  Version:  ' + JFileV ersion +
  2128           '  supported' )
  2129       else
  2130         LogI nterface.L ogText('Ja ws Check',  'Instance  Version:  ' + JFileV ersion +
  2131           '  not suppor ted');
  2132     end;
  2133     if ErrFo und then
  2134       ShowEr ror(JAWS_E RROR_VERSI ON);
  2135  
  2136     Result : = not ErrF ound;
  2137  
  2138   end;
  2139  
  2140   // ******* ********** ********** ********** ********** ********** *********
  2141   // Delete  Ini files
  2142   // ******* ********** ********** ********** ********** ********** *********
  2143   procedure  TJAWSManag er.KillINI Files(Send er: TObjec t);
  2144   var
  2145     i: Integ er;
  2146   begin
  2147     for i :=  Low(JawsR ecord) to  High(JawsR ecord) do
  2148     begin
  2149       if ass igned(Jaws Record[i]. FDictionar yFile) the n
  2150       begin
  2151         if J awsRecord[ i].FDictio naryFileMo dified the n
  2152         begi n
  2153           Ma keFileWrit able(JawsR ecord[i].F Dictionary FileName);
  2154           Ja wsRecord[i ].FDiction aryFile.Sa veToFile
  2155              (JawsRecor d[i].FDict ionaryFile Name);
  2156         end;
  2157         Free AndNil(Jaw sRecord[i] .FDictiona ryFile);
  2158       end;
  2159  
  2160       if ass igned(Jaws Record[i]. FConfigINI File) then
  2161       begin
  2162         if J awsRecord[ i].FConfig INIFileMod ified then
  2163         begi n
  2164           Ja wsRecord[i ].FConfigI NIFile.Upd ateFile;
  2165         end;
  2166         Free AndNil(Jaw sRecord[i] .FConfigIN IFile);
  2167       end;
  2168  
  2169       if ass igned(Jaws Record[i]. FKeyMapINI File) then
  2170       begin
  2171         if J awsRecord[ i].FKeyMap INIFileMod ified then
  2172         begi n
  2173           Ja wsRecord[i ].FKeyMapI NIFile.Upd ateFile;
  2174         end;
  2175         Free AndNil(Jaw sRecord[i] .FKeyMapIN IFile);
  2176       end;
  2177  
  2178       if ass igned(Jaws Record[i]. FAssignedK eys) then
  2179         Free AndNil(Jaw sRecord[i] .FAssigned Keys);
  2180     end;
  2181   end;
  2182  
  2183   // ******* ********** ********** ********** ********** ********** *********
  2184   // Create  the dispat cher windo w
  2185   // ******* ********** ********** ********** ********** ********** *********
  2186   procedure  TJAWSManag er.LaunchM asterAppli cation;
  2187   begin
  2188     if not a ssigned(FH iddenJaws)  then
  2189       FHidde nJaws := T frmVA508Ja wsDispatch erHiddenWi ndow.Creat e(Applicat ion);
  2190   end;
  2191  
  2192   procedure  TJAWSManag er.Registe rCustomBeh avior(Befo re, After:  string;
  2193     Action:  Integer);
  2194  
  2195   const
  2196     WindowCl assesSecti on = 'Wind owClasses' ;
  2197     MSAAClas sesSection  = 'MSAACl asses';
  2198     DICT_DEL IM: char =  char($2E) ;
  2199     CommonKe ysSection  = 'Common  Keys';
  2200     CustomCo mmandHelpS ection = ' Custom Com mand Help' ;
  2201     KeyComma nd = 'VA50 8SendCusto mCommand(' ;
  2202     KeyComma ndLen = Le ngth(KeyCo mmand);
  2203  
  2204   var
  2205     modified : Boolean;
  2206  
  2207     procedur e Add2INIF ile(var IN IFile: TIN IFile; var  FileModif ied: Boole an;
  2208       FileNa me, Sectio nName, dat a, Value:  string);
  2209     var
  2210       oldVal ue: string ;
  2211  
  2212     begin
  2213       if not  assigned( INIFile) t hen
  2214       begin
  2215         Make FileWritab le(FileNam e);
  2216         INIF ile := TIN IFile.Crea te(FileNam e);
  2217         File Modified : = FALSE;
  2218       end;
  2219       oldVal ue := INIF ile.ReadSt ring(Secti onName, da ta, '');
  2220       if old Value <> V alue then
  2221       begin
  2222         INIF ile.WriteS tring(Sect ionName, d ata, Value );
  2223         modi fied := TR UE;
  2224         File Modified : = TRUE;
  2225       end;
  2226     end;
  2227  
  2228     procedur e RemoveFr omINIFile( var INIFil e: TINIFil e; var Fil eModified:  Boolean;
  2229       FileNa me, Sectio nName, dat a: string) ;
  2230     var
  2231       oldVal ue: string ;
  2232  
  2233     begin
  2234       if not  assigned( INIFile) t hen
  2235       begin
  2236         Make FileWritab le(FileNam e);
  2237         INIF ile := TIN IFile.Crea te(FileNam e);
  2238         File Modified : = FALSE;
  2239       end;
  2240       oldVal ue := INIF ile.ReadSt ring(Secti onName, da ta, '');
  2241       if old Value <> ' ' then
  2242       begin
  2243         INIF ile.Delete Key(Sectio nName, dat a);
  2244         modi fied := TR UE;
  2245         File Modified : = TRUE;
  2246       end;
  2247     end;
  2248  
  2249     procedur e Register CustomClas sChange;
  2250     Var
  2251       i: Int eger;
  2252     begin
  2253       for i  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2254         Add2 INIFile(Ja wsRecord[i ].FConfigI NIFile,
  2255           Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e,
  2256           Wi ndowClasse sSection,  Before, Af ter);
  2257     end;
  2258  
  2259     procedur e Register MSAAClassC hange;
  2260     Var
  2261       i: Int eger;
  2262     begin
  2263       for i  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2264         Add2 INIFile(Ja wsRecord[i ].FConfigI NIFile,
  2265           Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e,
  2266           MS AAClassesS ection, Be fore, '1') ;
  2267     end;
  2268  
  2269     procedur e Register CustomKeyM apping;
  2270     Var
  2271       i: Int eger;
  2272     begin
  2273       for i  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2274       begin
  2275         Add2 INIFile(Ja wsRecord[i ].FKeyMapI NIFile,
  2276           Ja wsRecord[i ].FKeyMapI NIFileModi fied, Jaws Record[i]. FKeyMapFil e,
  2277           Co mmonKeysSe ction, Bef ore, KeyCo mmand + Af ter + ')') ;
  2278         if n ot assigne d(JawsReco rd[i].FAss ignedKeys)  then
  2279           Ja wsRecord[i ].FAssigne dKeys := T StringList .Create;
  2280         Jaws Record[i]. FAssignedK eys.Add(Be fore);
  2281       end;
  2282     end;
  2283  
  2284     procedur e Register CustomKeyD escription ;
  2285     Var
  2286       i: Int eger;
  2287     begin
  2288       for i  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2289         Add2 INIFile(Ja wsRecord[i ].FConfigI NIFile,
  2290           Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e,
  2291           Cu stomComman dHelpSecti on, Before , After);
  2292     end;
  2293  
  2294     procedur e DecodeLi ne(line: s tring; var  before1,  after1: st ring);
  2295     var
  2296       i, j,  Len: Integ er;
  2297     begin
  2298       before 1 := '';
  2299       after1  := '';
  2300       Len :=  Length(li ne);
  2301       if (Le n < 2) or  (line[1] < > DICT_DEL IM) then
  2302         Exit ;
  2303       i := 2 ;
  2304       while  (i < Len)  and (line[ i] <> DICT _DELIM) do
  2305         Inc( i);
  2306       before 1 := Copy( line, 2, i  - 2);
  2307       j := i  + 1;
  2308       while  (j <= Len)  and (line [j] <> DIC T_DELIM) d o
  2309         Inc( j);
  2310       after1  := Copy(l ine, i + 1 , j - i -  1);
  2311     end;
  2312  
  2313     procedur e Register CustomDict ionaryChan ge;
  2314     var
  2315       i, idx , X: Integ er;
  2316       line,  before1, a fter1: str ing;
  2317       Add: B oolean;
  2318     begin
  2319       for X  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2320       begin
  2321         if n ot assigne d(JawsReco rd[X].FDic tionaryFil e) then
  2322         begi n
  2323           Ja wsRecord[X ].FDiction aryFile :=  TStringLi st.Create;
  2324           Ja wsRecord[X ].FDiction aryFileMod ified := F ALSE;
  2325           if  FileExist s(JawsReco rd[X].FDic tionaryFil eName) the n
  2326              JawsRecord [X].FDicti onaryFile. LoadFromFi le
  2327                (JawsRec ord[X].FDi ctionaryFi leName);
  2328         end;
  2329  
  2330         Add  := TRUE;
  2331         idx  := -1;
  2332         for  i := 0 to  JawsRecord [X].FDicti onaryFile. Count - 1  do
  2333         begi n
  2334           li ne := Jaws Record[X]. FDictionar yFile[i];
  2335           De codeLine(l ine, befor e1, after1 );
  2336           if  (before1  = Before)  then
  2337           be gin
  2338              idx := i;
  2339              if after1  = After th en
  2340                Add := F ALSE;
  2341              break;
  2342           en d;
  2343         end;
  2344         if A dd then
  2345         begi n
  2346           li ne := DICT _DELIM + B efore + DI CT_DELIM +  After + D ICT_DELIM;
  2347           if  idx < 0 t hen
  2348              JawsRecord [X].FDicti onaryFile. Add(line)
  2349           el se
  2350              JawsRecord [X].FDicti onaryFile[ idx] := li ne;
  2351           mo dified :=  TRUE;
  2352           Ja wsRecord[X ].FDiction aryFileMod ified := T RUE;
  2353         end;
  2354       end;
  2355     end;
  2356  
  2357     procedur e RemoveCo mponentCla ss;
  2358     Var
  2359       i: Int eger;
  2360     begin
  2361       for i  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2362         Remo veFromINIF ile(JawsRe cord[i].FC onfigINIFi le,
  2363           Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e,
  2364           Wi ndowClasse sSection,  Before);
  2365     end;
  2366  
  2367     procedur e RemoveMS AAClass;
  2368     Var
  2369       i: Int eger;
  2370     begin
  2371       for i  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2372         Remo veFromINIF ile(JawsRe cord[i].FC onfigINIFi le,
  2373           Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e,
  2374           MS AAClassesS ection, Be fore);
  2375     end;
  2376  
  2377     procedur e PurgeKey Mappings;
  2378     var
  2379       i, X:  Integer;
  2380       Name,  Value: str ing;
  2381       keys:  TStringLis t;
  2382       delete : Boolean;
  2383     begin
  2384       for X  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2385       begin
  2386         if n ot assigne d(JawsReco rd[X].FKey MapINIFile ) then
  2387         begi n
  2388           Ma keFileWrit able(JawsR ecord[X].F KeyMapFile );
  2389           Ja wsRecord[X ].FKeyMapI NIFile :=
  2390              TINIFile.C reate(Jaws Record[X]. FKeyMapFil e);
  2391           Ja wsRecord[X ].FKeyMapI NIFileModi fied := FA LSE;
  2392         end;
  2393         keys  := TStrin gList.Crea te;
  2394         try
  2395           Ja wsRecord[X ].FKeyMapI NIFile.Rea dSectionVa lues(Commo nKeysSecti on, keys);
  2396           fo r i := key s.Count -  1 downto 0  do
  2397           be gin
  2398              Value := C opy(keys.V alueFromIn dex[i], 1,  KeyComman dLen);
  2399              if Value =  KeyComman d then
  2400              begin
  2401                name :=  keys.Names [i];
  2402                delete : = (not ass igned(Jaws Record[X]. FAssignedK eys));
  2403                if not d elete then
  2404                  delete  := (JawsR ecord[X].F AssignedKe ys.IndexOf (name) < 0 );
  2405                if delet e then
  2406                begin
  2407                  JawsRe cord[X].FK eyMapINIFi le.DeleteK ey(CommonK eysSection , name);
  2408                  JawsRe cord[X].FK eyMapINIFi leModified  := TRUE;
  2409                  modifi ed := TRUE ;
  2410                end;
  2411              end;
  2412           en d;
  2413         fina lly
  2414           ke ys.free;
  2415         end;
  2416       end;
  2417     end;
  2418  
  2419   begin
  2420     { TODO :  check fil e io error s when upd ating conf ig files }
  2421     modified  := FALSE;
  2422     case Act ion of
  2423       BEHAVI OR_ADD_DIC TIONARY_CH ANGE:
  2424         Regi sterCustom Dictionary Change;
  2425       BEHAVI OR_ADD_COM PONENT_CLA SS:
  2426         Regi sterCustom ClassChang e;
  2427       BEHAVI OR_ADD_COM PONENT_MSA A:
  2428         Regi sterMSAACl assChange;
  2429       BEHAVI OR_ADD_CUS TOM_KEY_MA PPING:
  2430         Regi sterCustom KeyMapping ;
  2431       BEHAVI OR_ADD_CUS TOM_KEY_DE SCRIPTION:
  2432         Regi sterCustom KeyDescrip tion;
  2433       BEHAVI OR_REMOVE_ COMPONENT_ CLASS:
  2434         Remo veComponen tClass;
  2435       BEHAVI OR_REMOVE_ COMPONENT_ MSAA:
  2436         Remo veMSAAClas s;
  2437       BEHAVI OR_PURGE_U NREGISTERE D_KEY_MAPP INGS:
  2438         Purg eKeyMappin gs;
  2439     end;
  2440     if modif ied and as signed(FMa inForm) th en
  2441     begin
  2442       FMainF orm.ResetI NITimer(Ki llINIFiles );
  2443       FMainF orm.Config ReloadNeed ed;
  2444     end;
  2445   end;
  2446  
  2447   // ******* ********** ********** ********** ********** ********** *********
  2448   // Fires o ff the rel oad all co nfigs thro ugh Jaws
  2449   // ******* ********** ********** ********** ********** ********** *********
  2450   procedure  TJAWSManag er.ReloadC onfigurati on;
  2451   begin
  2452     if not a ssigned(JA WSAPI) the n
  2453       JAWSAP I := CoJaw sApi.Creat e;
  2454     JAWSAPI. RunFunctio n('ReloadA llConfigs' );
  2455   end;
  2456  
  2457   // ******* ********** ********** ********** ********** ********** *********
  2458   // Send ei ther data  or event t o Jaws
  2459   // ******* ********** ********** ********** ********** ********** *********
  2460   procedure  TJAWSManag er.SendCom ponentData (WindowHan dle: HWND;
  2461     DataStat us: LongIn t; Caption , Value, d ata, Contr olType, St ate, Instr uctions,
  2462     ItemInst ructions:  PChar);
  2463  
  2464   // ******* ********** ********** ********** ********** ********** *********
  2465   // Send to  dispatche r
  2466   // ******* ********** ********** ********** ********** ********** *********
  2467     procedur e SendRequ estRespons e;
  2468     begin
  2469       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_CAPTIO N, Caption );
  2470       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_VALUE,  Value);
  2471       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_CONTRO L_TYPE, Co ntrolType) ;
  2472       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_STATE,  State);
  2473       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_INSTRU CTIONS, In structions );
  2474       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_ITEM_I NSTRUCTION S,
  2475         Item Instructio ns);
  2476       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_DATA_S TATUS, Int ToStr(Data Status));
  2477       FMainF orm.PostDa ta;
  2478     end;
  2479  
  2480   // ******* ********** ********** ********** ********** ********** *********
  2481   // Run the  change ev ent throug h Jaws
  2482   // ******* ********** ********** ********** ********** ********** *********
  2483     procedur e SendChan geEvent;
  2484     var
  2485       Event:  WideStrin g;
  2486     begin
  2487       Event  := 'VA508C hangeEvent (' + IntTo Str(Window Handle) +  ',' +
  2488         IntT oStr(DataS tatus) + ' ,"' + StrP as(Caption ) + '","'  + StrPas(V alue) +
  2489         '"," ' + StrPas (ControlTy pe) + '"," ' + StrPas (State) +  '","' +
  2490         StrP as(Instruc tions) + ' ","' + Str Pas(ItemIn structions ) + '"';
  2491       if not  assigned( JAWSAPI) t hen
  2492         JAWS API := CoJ awsApi.Cre ate;
  2493       JAWSAP I.RunFunct ion(Event)
  2494     end;
  2495  
  2496   begin
  2497     if (data  <> nil) a nd (Length (data) > 0 ) then
  2498     begin
  2499       Value  := data;
  2500       DataSt atus := Da taStatus A ND DATA_MA SK_DATA;
  2501       DataSt atus := Da taStatus O R DATA_VAL UE;
  2502     end;
  2503     if (Data Status and  DATA_CHAN GE_EVENT)  <> 0 then
  2504     begin
  2505       DataSt atus := Da taStatus A ND DATA_MA SK_CHANGE_ EVENT;
  2506       SendCh angeEvent;
  2507     end
  2508     else
  2509       SendRe questRespo nse;
  2510   end;
  2511  
  2512   // ******* ********** ********** ********** ********** ********** *********
  2513   // Display  a certian  error
  2514   // ******* ********** ********** ********** ********** ********** *********
  2515   class proc edure TJAW SManager.S howError(E rrorNumber : Integer) ;
  2516   begin
  2517     ShowErro r(ErrorNum ber, []);
  2518   end;
  2519  
  2520   // ******* ********** ********** ********** ********** ********** *********
  2521   // Display  a certian  formated  error
  2522   // ******* ********** ********** ********** ********** ********** *********
  2523   class proc edure TJAW SManager.S howError(E rrorNumber : Integer;
  2524     data: ar ray of con st);
  2525   var
  2526     error: s tring;
  2527  
  2528   begin
  2529     if not J AWSErrorsS hown[Error Number] th en
  2530     begin
  2531       error  := JAWSErr orMessage[ ErrorNumbe r];
  2532       if Len gth(data)  > 0 then
  2533         erro r := Forma t(error, d ata);
  2534       JAWSEr rorsShown[ ErrorNumbe r] := TRUE ;
  2535       if ass igned(User Splash) th en
  2536         User Splash.Sho wSystemErr or('JAWS A ccessibili ty Compone nt Error'  + CRLF +
  2537           PC har(error) )
  2538       else
  2539         Mess ageBox(0,  PChar(erro r), 'JAWS  Accessibil ity Compon ent Error' ,
  2540           MB _OK or MB_ ICONERROR  or MB_TASK MODAL or M B_TOPMOST) ;
  2541  
  2542     end;
  2543   end;
  2544  
  2545   // ******* ********** ********** ********** ********** ********** *********
  2546   // Clean u p files an d memory
  2547   // ******* ********** ********** ********** ********** ********** *********
  2548   procedure  TJAWSManag er.ShutDow n;
  2549   var
  2550     i: Integ er;
  2551   begin
  2552     if FWasS hutdown th en
  2553       Exit;
  2554     if assig ned(JAWSAP I) then
  2555     begin
  2556       try
  2557         JAWS API := nil ; // cause s access v iolation
  2558       except
  2559       end;
  2560     end;
  2561     KillINIF iles(nil);
  2562     if assig ned(FMainF orm) then
  2563       FreeAn dNil(FMain Form);
  2564     FWasShut down := TR UE;
  2565     if assig ned(FHidde nJaws) the n
  2566       FHidde nJaws.free ;
  2567     SetLengt h(JawsReco rd, 0);
  2568     for i :=  Low(Scrip tFiles) to  High(Scri ptFiles) d o
  2569     begin
  2570       SetLen gth(Script Files[i].A dd_To_Uses , 0);
  2571       SetLen gth(Script Files[i].D ependencie s, 0);
  2572     end;
  2573     SetLengt h(ScriptFi les, 0);
  2574   end;
  2575  
  2576   // ******* ********** ********** ********** ********** ********** *********
  2577   // Say a s pecific st ring throu gh Jaws
  2578   // ******* ********** ********** ********** ********** ********** *********
  2579   procedure  TJAWSManag er.SpeakTe xt(Text: P Char);
  2580   begin
  2581     if not a ssigned(JA WSAPI) the n
  2582       JAWSAP I := CoJaw sApi.Creat e;
  2583     JAWSAPI. SayString( Text, FALS E);
  2584   end;
  2585  
  2586   // ******* ********** ********** ********** ********** ********** *********
  2587   // Ensure  the hidden  main wind ow is crea ted and re compile
  2588   // ******* ********** ********** ********** ********** ********** *********
  2589   procedure  TJAWSManag er.EnsureW indow;
  2590   begin
  2591     if not a ssigned(FM ainForm) t hen
  2592       FMainF orm := Tfr mVA508Hidd enJawsMain Window.Cre ate(nil);
  2593     FMainFor m.Componen tDataCallB ackProc :=  fComponen tCallBackP roc;
  2594     FMainFor m.ConfigRe loadProc : = ReloadCo nfiguratio n;
  2595     FMainFor m.HandleNe eded;
  2596     Applicat ion.Proces sMessages;
  2597   end;
  2598  
  2599   {$REGION ' ********** ********** ****** Arc hived Meth od ******* ********** ********'}
  2600   {
  2601     class fu nction TJA WSManager. GetPathFro mJAWS(Path ID: Intege r;
  2602     DoLowerC ase: boole an = TRUE) : string;
  2603     const
  2604     JAWS_MES SAGE_ID =  'JW_GET_FI LE_PATH';
  2605     // versi on is in d irectory a fter JAWS  \Freedom S cientific\ JAWS\*.*\. ..
  2606     JAWS_PAT H_ID_APPLI CATION = 0 ;
  2607     JAWS_PAT H_ID_USER_ SCRIPT_FIL ES = 1;
  2608     JAWS_PAT H_ID_JAWS_ DEFAULT_SC RIPT_FILES  = 2;
  2609     // 0 = C :\Program  Files\Free dom Scient ific\JAWS\ 8.0\jfw.IN I
  2610     // 1 = D :\Document s and Sett ings\vhais lmerrij\Ap plication  Data\Freed om Scienti fic\JAWS\8 .0\USER.IN I
  2611     // 2 = D :\Document s and Sett ings\All U sers\Appli cation Dat a\Freedom  Scientific \JAWS\8.0\ Settings\e nu\DEFAULT .SBL
  2612     var
  2613     atm: ATO M;
  2614     len: Int eger;
  2615     path: st ring;
  2616     JAWSWind ow: HWND;
  2617     JAWSMsgI D: UINT =  0;
  2618     begin
  2619     JAWSWind ow := GetJ AWSWindow;
  2620     if JAWSM sgID = 0 t hen
  2621     JAWSMsgI D := Regis terWindowM essage(JAW S_MESSAGE_ ID);
  2622     Result : = '';
  2623     atm := S endMessage (JAWSWindo w, JAWSMsg ID, PathID , 0);
  2624     if atm < > 0 then
  2625     begin
  2626     SetLengt h(path, MA X_PATH * 2 );
  2627     len := G lobalGetAt omName(atm , PChar(pa th), MAX_P ATH * 2);
  2628     GlobalDe leteAtom(a tm);
  2629     if len >  0 then
  2630     begin
  2631     SetLengt h(path, le n);
  2632     Result : = ExtractF ilePath(pa th);
  2633     if DoLow erCase the n
  2634     Result : = LowerCas e(Result);
  2635     end;
  2636     end;
  2637     end;
  2638   }
  2639   {$ENDREGIO N}
  2640   {$ENDREGIO N}
  2641   { function  tCompileF ile.Compil eFile(var  RtnMsg: St ring): int eger;
  2642     begin
  2643     result : = ExecuteA ndWait('"'  + Compile r + '"', R tnMsg, '"'  + FileNam e + '"');
  2644     end; }
  2645  
  2646   function t CompileFil e.CompileF ile(var Rt nMsg: Stri ng): Boole an;
  2647   var
  2648     RtnLst:  TStringLis t;
  2649   begin
  2650     RtnLst : = TStringL ist.Create ;
  2651     try
  2652       Result  := RunSil entCmd(Com piler, Fil eName, Rtn Msg);
  2653       RtnLst .Text := R tnMsg;
  2654       if Rtn Lst.Count  > 1 then
  2655         Resu lt := FALS E;
  2656  
  2657     finally
  2658       RtnLst .free;
  2659     end;
  2660  
  2661   end;
  2662  
  2663   Function F indCommand Switch(Swi tchName: s tring; var  ReturnVal ue: string )
  2664     : Boolea n;
  2665   begin
  2666   {$IFDEF VE R180}
  2667     Result : = D2006Fin dCmdLineSw itch('Swit chName', R eturnValue , TRUE,
  2668       [clstD 2006ValueA ppended]);
  2669   {$ELSE}
  2670     Result : = FindCmdL ineSwitch( 'SwitchNam e', Return Value, TRU E,
  2671       [clstV alueAppend ed]);
  2672   {$ENDIF}
  2673   end;
  2674  
  2675   Function F indCommand Switch(Swi tchName: s tring): Bo olean;
  2676   begin
  2677   {$IFDEF VE R180}
  2678     Result : = D2006Fin dCmdLineSw itch(Switc hName, ['- '], TRUE);
  2679   {$ELSE}
  2680     Result : = FindCmdL ineSwitch( SwitchName , ['-'], T RUE);
  2681   {$ENDIF}
  2682   end;
  2683  
  2684   initializa tion
  2685  
  2686   LogInterfa ce.Active  := FindCom mandSwitch ('JL');
  2687  
  2688   CoInitiali zeEx(nil,  COINIT_APA RTMENTTHRE ADED); //  COINIT_MUL TITHREADED );
  2689  
  2690   Applicatio n.MainForm OnTaskbar  := TRUE;
  2691  
  2692   finalizati on
  2693  
  2694   ShutDown;
  2695  
  2696   CoUninitia lize;
  2697  
  2698   end.