Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Path to a program
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01151910
Message ID:
01151987
Views:
58
>Naomi,
>
>If the command line interface is installed via normal method then it's registered and you can find the location from the registry. The following code will return its location:
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 && FindWzzip
As 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.
>
>OTOH if the program run by oShell.Run actually executes but has some kind of error of its own, your Catch will not pick that up. In that case the return value from oShell.Run is the code returned by the spawned program.
>
>-Rick
>
Rick, thanks a lot. I'm going to try your code. I'm not sure why my Catch doesn't show that the program doesn't exist. I think it used to do that but not anymore. The return value is 0, but I know that it was not even run.

The Help for WzZip says:

Using return codes (errorlevels)

WZZIP and WZUNZIP will in most cases return a nonzero errorlevel in the event of a serious error; otherwise, an errorlevel of 0 is returned. You can use these return codes in batch files and other automated processing. For example:

wzzip filename.zip *.doc
If ErrorLevel 1 Goto ErrMsg

Echo No Known Errors

Goto Exit

:ErrMsg

Echo ***SERIOUS ERROR DETECTED***
:Exit
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform