FUNCTION FindWzzip() as String #DEFINE HKEY_LOCAL_MACHINE -2147483646 && BITSET(0,31)+2 LOCAL lcWzzipKey, lcValue, lnErrorCode, loReg lcWzzipKey = "Software\Microsoft\Windows\CurrentVersion\app paths\wzzip.exe" && In the HKLM hive. lcValue = "" lnErrorCode = 0 TRY loReg = NewObject( "Registry", HOME(1) + "FFC\Registry.VCX") * Does the wzzip.exe app path key exist? IF loReg.IsKey( lcWzzipKey, HKEY_LOCAL_MACHINE) * If so, get its value. lnErrorCode = loReg.GetRegKey( "", @lcValue, lcWzzipKey, HKEY_LOCAL_MACHINE) IF lnErrorCode = 0 && No error. * Registered location of wzzip.exe is in lcValue. ELSE * Handle error: error reading registry key. ENDIF ENDIF CATCH TO loError * Handle error ENDTRY RETURN lcValue ENDFUNC && FindWzzipAs for your other question, it depends on what kind of error occurs. If the program run by oShell.Run does not exist your Catch will pick it up, unless m.tlSilentMode does not exist in which case you will get an unhandled structured exception.
>local oShell, llError, loException >llError = .f. >try > oShell = createobject("WScript.Shell") >catch to loException > if m.tlSilentMode > tcRetVal = "Run-time error: WScript.Shell Object is not Found" > else > =messagebox("Run-time error: WScript.Shell Object is not Found") > endif > llError = .t. >endtry >if m.llError <> .t. > try >* SW_SHOW_HIDDEN 0,SW_SHOW_NORMAL 1,SW_SHOW_MINIMIZED 2,SW_SHOW_MAXIMIZED 3 > oShell.run(m.tcCommand, 0,.t.) catch to loException > if m.tlSilentMode > tcRetVal = "Run-time error: WScript.Shell: " + ; > m.tcCommand + chr(13) + chr(10) + Log_Error(m.loException) > else > =messagebox("Run-time error: WScript.Shell: " + m.tcCommand) > endif > llError = .t. > endtry >endif >release oShell > >return !llError >>